#include <bits/stdc++.h>
using namespace std;
long long pagal[1000005];
void code() {
  long long n, x;
  cin >> n;
  long long ms = 0, f = 0;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    pagal[x]++;
    if (pagal[x] > pagal[ms]) {
      ms = x;
    }
  }
  cout << ms << endl;
}
signed main() { code(); }
