#include <bits/stdc++.h>
using namespace std;
int p[1000005];
int q[1000005];
int main() {
  int i, n, maxv = 0, maxn = 0;
  cin >> n;
  memset(q, 0, sizeof(q));
  for (i = 0; i < n; i++) cin >> p[i];
  for (i = 0; i < n; i++) {
    q[p[i]]++;
    if (q[p[i]] > maxv) {
      maxv = q[p[i]];
      maxn = p[i];
    }
  }
  cout << maxn << endl;
  return 0;
}
