#include <bits/stdc++.h>
using namespace std;
int a[1000001], x, maxx, n, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    a[x]++;
    if (a[x] > maxx) {
      maxx = a[x];
      ans = x;
    }
  }
  cout << ans;
  return 0;
}
