#include <bits/stdc++.h>
using namespace std;

signed main(){
    ios::sync_with_stdio(false);

    unsigned long long n; // n <= 1e6
    long long m = 1000;
    long long o = 1000000;
    long long largest_pos[o];
    long long largest_nextpos = 1;
    cin >> n;
    unsigned long long a[m]; // a <= 1000
    for (long long i = 1; i <= n; i++){
        cin >> m;
        a[m]++;
        if (a[m] > a[largest_pos[largest_nextpos]]){
            largest_pos[1]=m;
            largest_nextpos=1;
        }
        else if (a[m] = a[largest_pos[largest_nextpos]]){
            largest_nextpos++;
        }
        else continue;
    }
    //for (long long j = 1; j <= n;)
}