#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int dx4[] = {+1, -1, +0, +0};
int dy4[] = {+0, +0, +1, -1};
int dx8[] = {+0, +0, -1, +1, -1, -1, +1, +1};
int dy8[] = {-1, +1, +0, +0, -1, +1, -1, +1};
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
void test_case() {
  int n;
  cin >> n;
  const int MAX = 1e6 + 6;
  int ans, id, cnt[MAX] = {}, maxi = INT_MIN;
  for (int i = 1; i <= (int)(n); ++i) {
    cin >> id;
    cnt[id]++;
    if (maxi < cnt[id]) {
      maxi = cnt[id];
      ans = id;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(15);
  cout << fixed;
  int T = 1;
  for (int tc = 1; tc <= T; ++tc) {
    test_case();
  }
  return 0;
}
