#include #include #include using namespace std; template inline T in() { T x; cin >> x; return x; } int main() { int n; cin >> n; vector cnt(n + 1); for (int i = 0; i < n; i++) cnt[in()]++; int ma = *max_element(begin(cnt), end(cnt)); int p = n; while (cnt[p] != ma) p--; cout << p << endl; return 0; }