#include<iostream>
#include<unordered_map>
using namespace std;
unordered_map<int,int> s;
int res = 0x3f3f3f3f;
int main()
{
int n,max_num = 0;
cin >> n;
for(int i = 0; i < n; i ++)
{
int x;
cin >> x;
s[x] ++;
max_num = max(max_num,s[x]);
}
auto it = s.begin();
while(it != s.end())
{
if(it->second == max_num)
res = min(res,it->first);
it ++;
}
cout << res << endl;
return 0;
}