#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const double eps = 1e-9;
int a[1000111];
int main() {
  int n;
  cin >> n;
  int be = 0;
  int ans = -1;
  while (n--) {
    int x;
    cin >> x;
    a[x]++;
    if (a[x] > be) {
      be = a[x];
      ans = x;
    }
  }
  cout << ans << endl;
  return 0;
}
