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