#include <iostream>
using namespace std;
const int N = 1E4 + 10;
int mp[N];
int main(){
int n; cin >> n;
for(int i = 0; i < n; i ++ ){
int tmp; cin >> tmp;
mp[tmp] ++ ;
}
int res = 0, maxv = 0;
for(int i = N - 1; i >= 1; i -- ){
if(mp[i] >= maxv){
maxv = mp[i];
res = i;
}
}
cout << res << endl;
return 0;
}