#include <bits/stdc++.h>
using namespace std;
int main() {
  map<long, long> ph, q;
  long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long a;
    cin >> a;
    ph[a] += 1;
    q[a] = i;
  }
  long mx = 0, mi = -1;
  for (map<long, long>::iterator it = ph.begin(); it != ph.end(); it++) {
    if (it->second > mx ||
        (it->second == mx && (mi != -1 ? q[it->first] < q[mi] : 1))) {
      mx = it->second;
      mi = it->first;
    }
  }
  cout << mi;
}
