#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  map<int, int> m;
  int max = 0;
  int winner;
  int t;
  for (int i = 0; i < N; i++) {
    cin >> t;
    m[t]++;
    if (m[t] > max) {
      max = m[t];
      winner = t;
    }
  }
  cout << winner << endl;
}
