#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, j, k, ans = 0;
  map<int, int> a;
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> n;
    a[n]++;
    if (a[n] > a[ans]) {
      ans = n;
    }
  }
  cout << ans << endl;
}
