解题思路:简单模拟,/*今天很挫败,人生不如意事,十有八九,不必强求,但定要努力,努是尽的意思。不断地超越自己这就是我活下来地意义。 */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=10005;
struct node
{
int v;
int num;
}a[N];
int cmp(node b,node c){
if(b.num>c.num)return true;
else if(b.num==c.num){
if(b.v<c.v)return true;
else return false;
}
return false;
}
int main(){
int n;
int v;
cin>>n;
for(int i=0;i<n;i++){
cin>>v;
a[v].v=v;
a[v].num++;
}
sort(a,a+N,cmp);
cout<<a[0].v<<endl;
return 0;
}