#include <bits/stdc++.h>
short int mas[1000002], mas1[1000002];
int main() {
  long long n;
  scanf("%I64d", &n);
  int m[1002], max = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m[i]);
    ++mas[m[i]];
    if (max < mas[m[i]]) max = mas[m[i]];
  }
  for (int i = 0; i < n; ++i) {
    ++mas1[m[i]];
    if (max == mas1[m[i]]) {
      printf("%d", m[i]);
      break;
    }
  }
  return 0;
}
