#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return (a > b); }
int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int m[1000001] = {0};
int main(void) {
  int n;
  cin >> n;
  int a, ma = 0, i, ans;
  for (i = 0; i < n; ++i) {
    cin >> a;
    m[a]++;
    if (ma < m[a]) {
      ans = a;
      ma = m[a];
    }
  }
  cout << ans;
  return 0;
}
