#include <bits/stdc++.h>
using namespace std;
long long a, b, kol1, kol2, ch, i, j, n, sum, q1, q2, m, k, l, r, c, kol,
    indexx, q, nach, kon, st, maxl, minl, x, wer_ery, sum1, sum2, ot, mn, ln,
    sts, start, fin, raz, kk, len;
map<long long, long long> t;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> k;
    t[k]++;
    if (t[k] > maxl) {
      maxl = t[k];
      indexx = k;
    }
  }
  cout << indexx;
}
