#include <bits/stdc++.h>
using namespace std;
int a, b[1000002], c = 0, d, e, f, g, h, i, j;
int main() {
  cin >> a;
  for (i = 1; i <= a; i++) {
    cin >> d;
    b[d]++;
    if (b[d] > c) {
      c = b[d];
      e = d;
    }
  }
  cout << e;
  return 0;
}
