#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, buf, m;
  vector<int> a;
  map<int, int> b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> buf;
    a.push_back(buf);
    if (b.find(buf) != b.end())
      b[buf] += 1;
    else
      b[buf] = 1;
  }
  m = 0;
  for (int i = 0; i < n; i++) {
    if (b[a[i]] > m) m = b[a[i]];
  }
  b.clear();
  for (int i = 0; i < n; i++) {
    if (b.find(a[i]) != b.end())
      b[a[i]] += 1;
    else
      b[a[i]] = 1;
    if (m == b[a[i]]) {
      cout << a[i] << endl;
      return 0;
    }
  }
  return 0;
}
