#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int smax = 0, kmax = 0;
  int n;
  unordered_map<int, int> map;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int ta;
    cin >> ta;
    if (map.find(ta) != map.end()) {
      map[ta]++;
      if (map[ta] > smax) {
        smax = map[ta];
        kmax = ta;
      }
    } else {
      map[ta] = 1;
      if (map[ta] > smax) {
        smax = map[ta];
        kmax = ta;
      }
    }
  }
  cout << kmax;
  return 0;
}
