#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <queue>
# include <unordered_map>
using namespace std;


#define all(v) (v).begin(),(v).end()
#define sz(a) int((a).size())
#define PB push_back
#define mem(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define EPS      1e-9
#define oo       1e9
#define OO       1e14*1LL
#define PI       3.141592653589793
#define F        first
#define S        second
#define pw(x)	 (x)*(x)

typedef stringstream ss;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
const int dx[] = { 0, -1, 0, 1, -1, -1, 1, 1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

int main()
{
	int n,m=0,id=oo, temp; cin >> n; map<int, int>mp; 
	for (int i = 0; i < n; i++) {
		cin >> temp;
		mp[temp]++;
	}
	for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
		m = max(m, it->second);
	}
	for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->second == m)
			id = min(id, it->first);
	}
	cout << id;
	return 0;
}