#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, a, ans;
int b[1000005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    b[a]++;
    if (b[a] > b[ans]) ans = a;
  }
  cout << ans << endl;
}
