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