#include using namespace std; int main(){ int n; cin >> n; vector types(n); for(int types_i = 0; types_i < n; types_i++){ cin >> types[types_i]; } vector freq(n); bool test = false; int temp; //sort for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(i > j){ temp = types[i]; types[i] = types[j]; types[j] = temp; } } } //get frequencies for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(types[i] == types[j]){ freq[i]++; } } } int max = *max_element(freq.begin(), freq.end()); int i = 0; for( ; i < n; i++){ if(types[i] == max) break; } printf("%d", types[max-1]); return 0; }