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