#include <bits/stdc++.h>
using namespace std;
int main() {
  long int k, max = 0, n, a[1000005] = {0}, ans;
  scanf("%ld", &n);
  while (n--) {
    scanf("%ld", &k);
    a[k]++;
    if (a[k] > max) {
      ans = k;
      max = a[k];
    }
  }
  printf("%ld\n", ans);
  return 0;
}
