#include <bits/stdc++.h>
int main() {
  int b, c = 0, i, j, k = 0, n, x = 0, z = 1000, p, y;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < n - 1; i++) {
    c = 0;
    for (j = i + 1; j < n; j++) {
      if (a[i] == a[j]) {
        c++;
        y = j;
      }
    }
    if (x == c && z > y) {
      p = i;
      x = c;
      z = y;
    } else if (x < c) {
      p = i;
      x = c;
      z = y;
    }
  }
  printf("%d", a[p]);
}
