#include <bits/stdc++.h>
using namespace std;
int n, m, k, mx, a[1111111];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> k;
    a[k]++;
    if (a[k] > mx) {
      mx = a[k];
      m = k;
    }
  }
  cout << m;
}
