#include <bits/stdc++.h>
const int N = 1e6;
int cnt[N], n, i;
int main() {
  scanf("%d", &n);
  int x = 0, p = 0, res = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x), cnt[x]++;
    cnt[x] > p ? p = cnt[x], res = x : false;
  }
  printf("%d\n", res);
}
