#include<iostream>
#include<unordered_map>
using namespace std;
unordered_map <int,int> ans;
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int x;
cin>>x;
ans[x]++;
}
int Max=-1;
int res=0;
for(auto x:ans)
{
if(x.second>Max)
{
res=x.first;
Max=x.second;
}
if(x.second==Max) res=min(x.first,res);
}
cout<<res;
return 0;
}