/* Author : Jordhy Fernando */
#include<bits/stdc++.h>
#define ll long long
#define For(i,j,n) for(int i = j; i < n; i++)
#define EPS 1e-12

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;


int main() {
    int n, type[6], ans, maks;
    cin >> n;
    maks = 0;
    ans = 0;
    for(int i = 0; i < 6; i++){
        type[i] = 0;
    }
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        type[x]++;
        if(maks < type[x]){
            maks = type[x];
            ans = x;
        }
        else if(maks == type[x]){
            if(ans > x){
                ans = x;
            }
        }
    }
    cout << ans << endl;
    return 0;
}