#include <bits/stdc++.h>
using namespace std;
vector<long long int> v, u;
unsigned long long arr[10000], b[10000];
int main() {
  long long int n, m = 0, k;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    for (long long int j = 0; j <= i; j++) {
      if (arr[i] == arr[j]) b[i]++;
    }
    if (b[i] > m) {
      m = b[i];
      k = i;
    }
  }
  cout << arr[k];
  return 0;
}
