#include <bits/stdc++.h>
using namespace std;
int main() {
map<int, int> m;
set<int> s;
int n, tmp;
cin >> n;
while(n--){
cin >> tmp;
s.insert(tmp);
if(m.find(tmp)!=m.end()){
m[tmp]++;
}else{
m.insert(pair<int, int>(tmp, 1));
}
}
for(int x : s){
cout << x << ' ' << m[x] << endl;
}
return 0;
}