#include <bits/stdc++.h>
using namespace std;
int testCase;
string s;
int iinf = 1e9 + 1;
long long inf = 1e16 + 1;
void solve() {
  long long n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  ;
  map<long long, long long> hmap;
  for (auto i : arr) hmap[i]++;
  ;
  long long m = 0;
  for (auto i : hmap) m = max(m, i.second);
  map<long long, long long> kmap;
  for (auto i : arr) {
    kmap[i]++;
    if (kmap[i] == m) {
      cout << i;
      return;
    }
  }
}
int main() {
  testCase = 1;
  while (testCase--) {
    solve();
    cout << "\n";
  }
}
