#include <bits/stdc++.h>
using namespace std;
int a[10000001] = {0};
int main() {
  int n, ans, max = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
    if (a[x] > max) {
      max = a[x];
      ans = x;
    }
  }
  cout << ans << endl;
  return 0;
}
