#include <bits/stdc++.h>
using namespace std;
int b[10000000];
int coun[10000000];
int main() {
  int n;
  cin >> n;
  int a[1020];
  int max = 0;
  memset(b, 0, sizeof(b));
  memset(coun, 0, sizeof(coun));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    b[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (b[a[i]] > max) max = b[a[i]];
  }
  for (int i = 0; i < n; i++) {
    coun[a[i]]++;
    if (coun[a[i]] == max) {
      cout << a[i] << endl;
      break;
    }
  }
  return 0;
}
