#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 9;
const long long mod = 1e9 + 7;
const long long maxn = 2e6 + 8;
long long n, k, a[maxn];
void solve() {
  long long i, j, x, ans = 0, mx = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    if (++a[x] > mx) mx = a[x], ans = x;
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
