#include <bits/stdc++.h>
using namespace std;
int fr[1000005];
int main() {
  int n, x;
  scanf("%d", &n);
  int ms = 0, f = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    ++fr[x];
    if (fr[x] > fr[ms]) {
      ms = x;
    }
  }
  printf("%d", ms);
}
