#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<int, int> votes;
  int maxk = -1, maxv = -1, n;
  cin >> n;
  while (n-- > 0) {
    int x;
    cin >> x;
    votes[x]++;
    if (votes[x] > maxv) maxv = votes[x], maxk = x;
  }
  cout << maxk << '\n';
  return 0;
}
