#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
const int MAXVAL = 1e6 + 10;
int n, a[MAXN];
int cnt[MAXVAL];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int mx = 0;
  for (int i = 0; i < n; i++) cin >> a[i], cnt[a[i]]++, mx = max(mx, cnt[a[i]]);
  memset(cnt, 0, sizeof(cnt));
  int ind = -1;
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
    if (cnt[a[i]] == mx) {
      ind = a[i];
      break;
    }
  }
  cout << ind << "\n";
  return 0;
}
