#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> arr(n);
map<int, int>m;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
m[arr[i]]++;
}
int res = INT_MIN;
map<int, int>::iterator it;
for (it = m.begin(); it != m.end(); it++)
{
if ((it->second) > m[res]) {
res = it->first;
}
cout << it->first << " " << it->second << endl;
}
cout << res;
return 0;
}
vector<int> GearNuma;
GearNuma.erase(remove(GearNuma.begin(), GearNuma.end(), 0), GearNuma.end());