#include<stdio.h>
int main(){
int n,i,j,count=0;
int max=0,min=0;
int s[10001];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&s[i]);
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(s[i]==s[j])
count++;
}
if(max<count){
max = count;
min = s[i];
}
if(max == count && s[i]<min){
min = s[i];
}
count = 0;
}
printf("%d",min);
return 0;
}