#include <iostream>
using namespace std;
int main()
{
int cnt[10010] = {0};
int n , res = 1000 , maxv = 0;
cin >> n;
while(n--)
{
int x;
cin >> x;
if(++cnt[x] > maxv || cnt[x] == maxv && x < res) res = x , maxv = max(maxv , cnt[x]);
}
cout << res << endl;
}