#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k, j, tmp = -1, c = 0, m = 10000, ans;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (a[i] == a[j]) c++, k = j;
    }
    if (tmp < c) tmp = c, ans = a[i], m = k;
    if (tmp == c && m > k) ans = a[i], tmp = c, m = k;
    c = 0;
  }
  cout << ans;
  return 0;
}
