#include <bits/stdc++.h>
using namespace std;
map<int, int> b;
int x, ans = 0, t = 0;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    b[x]++;
    if (b[x] > ans) {
      ans = b[x];
      t = x;
    }
  }
  cout << t;
  return 0;
}
