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