#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 7, MOD = 1e9 + 7, inf = 1e9, N = 1e4 + 7;
long long n, ans, a[maxN], x;
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    a[x]++;
    if (a[x] > a[ans]) ans = x;
  }
  return cout << ans << "\n", 0;
}
