#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000001000;
const int mod = 1000 * 1000 * 1000 + 7;
const int mod9 = 1000 * 1000 * 1000 + 9;
const double PI = 3.1415926535897932;
double sqr(double first) { return first * first; };
long double sqr(long double first) { return first * first; };
long long sqr(long long first) { return first * first; };
long long sqr(int first) { return first * 1LL * first; };
long long gcd(long long a, long long b) {
  while (b) a %= b, swap(a, b);
  return a;
}
long long bpm(long long a, long long n = -2, long long m = mod) {
  n = n >= 0 ? n : m + n;
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * a) % m;
    a = (a * a) % m;
    n >>= 1;
  }
  return r;
}
long long dist(long long x1, long long y1, long long x2, long long y2) {
  return sqr(x1 - x2) + sqr(y1 - y2);
}
std::ostream& operator<<(std::ostream& os, pair<int, int> p) {
  return os << "{" << p.first << " " << p.second << "}";
}
const int N = 202020;
map<int, int> mp;
int main() {
  pair<int, int> d(0, 0);
  int tests;
  scanf("%d", &tests);
  for (int test = 0; test < tests; test++) {
    int first;
    scanf("%d", &first);
    mp[first]++;
    pair<int, int> c(mp[first], first);
    if (c.first > d.first) d = c;
  }
  printf("%d\n", d.second);
  return 0;
}
