#include <bits/stdc++.h>
using namespace std;
long long int b[1000005] = {0}, c[1000006] = {0};
int main() {
  long long int n;
  cin >> n;
  long long int a[n], i;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    ++b[a[i]];
  }
  long long int large = 0;
  for (i = 1; i <= 1000000; ++i) {
    if (b[i] > large) large = b[i];
  }
  for (i = 0; i < n; ++i) {
    ++c[a[i]];
    if (c[a[i]] == large) {
      cout << a[i];
      break;
    }
  }
  return 0;
}
