#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000500;
const int inf = 2e9;
const double eps = 1e-8;
const int base = 1073676287;
int req[1050];
int a[maxn];
int main() {
  srand(time(0));
  int n;
  scanf("%d", &n);
  for (int j = 0; j < maxn; j++) a[j] = 0;
  int ma = 0;
  for (int j = 0; j < n; j++) {
    scanf("%d", &req[j]);
    a[req[j]]++;
    ma = max(ma, a[req[j]]);
  }
  for (int j = 0; j < maxn; j++) a[j] = 0;
  for (int j = 0; j < n; j++) {
    a[req[j]]++;
    if (a[req[j]] == ma) {
      printf("%d\n", req[j]);
      return 0;
    }
  }
  return 0;
}
