#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, X[1009];
  map<long, long> M;
  cin >> N;
  for (long i = 0; i < N; i++) cin >> X[i];
  for (long i = 0; i < N; i++) {
    if (M.find(X[i]) == M.end())
      M.insert(pair<long, long>(X[i], 1));
    else
      M[X[i]] += 1;
  }
  long max = -1, P;
  for (map<long, long>::iterator it = M.begin(); it != M.end(); it++)
    if (it->second > max) {
      max = it->second;
      P = it->first;
    }
  set<long> V;
  for (map<long, long>::iterator it = M.begin(); it != M.end(); it++)
    if (it->second == max) V.insert(it->first);
  for (long i = N - 1; i >= 0; i--) {
    if (V.size() == 1) break;
    V.erase(X[i]);
  }
  cout << *V.begin();
}
