#include <bits/stdc++.h>
using namespace std;
long long cnt[1000001], A[1000001];
int main() {
  memset(cnt, 0, sizeof cnt);
  ;
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  long long mx = 0, ans;
  for (int i = 1; i <= n; i++) mx = max(mx, cnt[A[i]]);
  memset(cnt, 0, sizeof cnt);
  ;
  for (int i = 1; i <= n; i++) {
    cnt[A[i]]++;
    if (mx == cnt[A[i]]) {
      ans = A[i];
      break;
    }
  }
  cout << ans << endl;
}
