#include <bits/stdc++.h>
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
using namespace std;
long long n, i, arr[1000005], kek, ans, ai;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &ai);
    arr[ai]++;
    if (arr[ai] > kek) kek = arr[ai], ans = ai;
  }
  printf("%d", ans);
}
