#include <bits/stdc++.h>
using namespace std;
int n, m, z;
int main() {
  int n, ans, mx = 0, x;
  long long i;
  scanf("%d", &n);
  int b[1000001];
  for (i = 1; i <= 1000000; i++) b[i] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    b[x]++;
    if (b[x] > mx) {
      mx = b[x];
      ans = x;
    }
  }
  printf("%d", ans);
  return 0;
}
