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