#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int maxLikes = 0, maxIndex = 0;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    m[x]++;
    if (maxLikes < m[x]) {
      maxLikes = m[x];
      maxIndex = x;
    }
  }
  cout << maxIndex;
}
