#include <bits/stdc++.h>
using namespace std;
int p[1000001];
int main() {
  int n, ind = 0, w, input;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> input;
    p[input]++;
    if (ind < p[input]) {
      ind = p[input];
      w = input;
    }
  }
  cout << w << endl;
}
