#include using namespace std; int main(){ int n; cin >> n; vector types(n); map counts; for(int types_i = 0; types_i < n; types_i++){ int tmp_val = 0; cin >> tmp_val; auto it = counts.find(tmp_val); if (it != counts.end()){ ++it->second; } else counts.insert(pair(tmp_val, 1)); } // your code goes here int max_counts_el = 0; int active_el = counts.begin()->first; for (auto i = counts.begin(); i!= counts.end(); ++i){ if (i->second > max_counts_el){ max_counts_el = i->second; active_el = i->first; } else if (i->second == max_counts_el && i->second < active_el){ active_el = i->second; } } cout << active_el; return 0; }