#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, id, mp = 0, mid;
  cin >> n;
  map<int, int> p;
  for (int i = 0; i < n; i++) {
    cin >> id;
    p[id]++;
    if (p[id] > mp) {
      mid = id;
      mp = p[id];
    }
  }
  cout << mid;
}
