#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
mp[x]++;
}
int ans=10005,p=0;
map<int, int>::iterator iter;
for(iter = mp.begin(); iter != mp.end(); iter++)
{
if(iter->second>p||iter->second==p&&iter->first<ans)ans=iter->first,p=iter->second;
}
cout<<ans;
return 0;
}