#include <bits/stdc++.h>
using namespace std;
const int sz = 1E6 + 5;
int x, p, n, i, a[sz], ansx = 0;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    a[x]++;
    if (a[x] > ansx) {
      ansx = a[x];
      p = x;
    }
  }
  cout << p;
  return 0;
}
