#include <bits/stdc++.h>
int v[1000005];
int main() {
  int i, j, k;
  int n, m, a, b;
  int f[1010];
  while (~scanf("%d", &n)) {
    memset(v, 0, sizeof(v));
    a = b = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &f[i]);
      v[f[i]]++;
      if (v[f[i]] > b) {
        a = f[i];
        b = v[f[i]];
      }
    }
    printf("%d\n", a);
  }
  return 0;
}
