#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, int> cntMap;
int main() {
  scanf("%d", &n);
  int res = -1;
  for (int _ = (0); _ < (n); _++) {
    int a;
    scanf("%d", &a);
    int &cnt = cntMap[a];
    cnt++;
    if (m < cnt) {
      m = cnt;
      res = a;
    }
  }
  printf("%d\n", res);
  return 0;
}
