#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(1000001, 0);
  int ans = 0, ct = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++arr[x];
    if (arr[x] > ct) {
      ct = arr[x];
      ans = x;
    }
  }
  cout << ans;
}
