#include <bits/stdc++.h>
using namespace std;
int arr[1000005] = {};
int likes[1001] = {};
int main() {
  ios_base::sync_with_stdio(0);
  int T = 1;
  for (int ttttt = 0; ttttt < T; ++ttttt) {
    int N;
    cin >> N;
    int maxLikes = 0;
    int lastLikeId = -1;
    for (int i = 0; i < N; ++i) {
      cin >> likes[i];
      ++arr[likes[i]];
      if (arr[likes[i]] > maxLikes) {
        maxLikes = arr[likes[i]];
        lastLikeId = likes[i];
      }
    }
    cout << lastLikeId << endl;
  }
  return 0;
}
