#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int cnt[1 << 20], id;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++cnt[x];
    if (cnt[x] > cnt[id]) {
      id = x;
    }
  }
  printf("%d\n", id);
  return 0;
}
