#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int m;
  map<int, int> like;
  vector<pair<int, int>> v;
  int max = -9999999, idphoto = 0;
  for (int i = 0; i < n; i++) {
    cin >> m;
    like[m]++;
    if (max < like[m]) {
      max = like[m];
      idphoto = m;
    }
  }
  cout << idphoto;
}
