#include <iostream>
using namespace std;
int main() {
int N, table[30001], maxCnt, index;
while ( cin >> N ) {
fill ( table, table + 30001, 0 );
maxCnt = 0;
for ( int i = 0; i < N; ++i ) {
cin >> index;
++table[index];
maxCnt = max ( maxCnt, table[index] );
}
for ( int i = 0; i < 30001; ++i )
if ( table[i] == maxCnt )
cout << i << " " << table[i] << endl;
}
return 0;
}