#include #define LL long long #define ULL unsigned long long #define REP(i,n) for(int i=0; i<(n); i++) #define REP2(i,x,n) for(int i=x; i<(n); i++) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int L; map mp; REP2( i, 0, N ) { cin >> L; mp[L]++; } int max{0}; for( auto x : mp ){ if( max < x.second ){ max = x.second; } } int max2{0}; for( auto x : mp ){ if( x.second == max ){ if( max2 < x.first ){ max2 = x.first; } } } auto it = mp.find( max2 ); cout << ( *it ).first << endl; return 0; }