#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128000000")
using namespace std;
const int MAXN = 1e5 + 200;
const int INF = int(1e9) + 7;
const long long LINF = 1ll * INF * INF;
const int md = int(1e9) + 7;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
int n, ansid, maxcnt;
int cnt[1111111];
int main() {
  cin >> n;
  maxcnt = ansid = -1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (++cnt[x] > maxcnt) {
      ansid = x;
      maxcnt = cnt[x];
    }
  }
  cout << ansid << endl;
  return 0;
}
