#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long bigmod(long long base, long long power) {
  if (power == 0) return 1;
  long long ret = bigmod(base, power / 2);
  ret = (ret * ret) % 1000000007;
  if (power & 1) ret = (ret * base) % 1000000007;
  return ret;
}
long long modInverse(long long n) {
  return (bigmod(n, 1000000007 - 2) % 1000000007);
}
const int MX = 1e6 + 7;
int store[MX] = {}, check[MX] = {}, id[1007], n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int p;
    scanf("%d", &p);
    id[i] = p;
    store[p]++;
  }
  int mx = -1;
  for (int i = 0; i < MX; i++) mx = max(mx, store[i]);
  for (int i = 0; i < n; i++) {
    check[id[i]]++;
    if (check[id[i]] == mx) {
      cout << id[i] << '\n';
      break;
    }
  }
  return 0;
}
