#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;
bool compare(pair<long long, int> a, pair<long long, int> b) {
if (a.second == b.second) {
return a.first < b.first;
}
return a.second > b.second;
}
int main() {
//freopen("input.txt", "rt", stdin);
int n;
scanf("%d", &n);
long long ans, input;
map<long long, int> m;
vector<pair<long long, int> > v;
for (int i = 0; i < n; i++) {
scanf("%lld", &input);
m[input]++;
}
copy(m.begin(), m.end(), back_inserter(v));
sort(v.begin(), v.end(), compare);
printf("%lld", v[0].first);
return 0;
}