#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int main() {
  srand(time(NULL));
  int n;
  scanf("%d", &n);
  int ans = 0;
  int k = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    int res = ++m[x];
    if (res > k) {
      ans = x;
      k = res;
    }
  }
  printf("%d\n", ans);
  fprintf(stderr, "Execution time = %.4lfsec",
          (double)clock() / (double)CLOCKS_PER_SEC);
  return 0;
}
