#define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mpair make_pair #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; typedef long double ld; const ld epsylon = 1e-9; int main() { freopen("pooh.in","r",stdin); freopen("pooh.out","w",stdout); int n; cin >> n; map a; int temp; for (int i=0;i> temp; if (a.count(temp) == 0) { a.insert(mpair(temp, 1)); } else { a[temp]++; } } int bestv = -1; int best = -1; for (map::reverse_iterator it = a.rbegin(); it != a.rend(); ++it) { if (it->second * it-> first > bestv) { best = it->first; bestv = it->second * it-> first; } } cout << best << endl; return 0; }