#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int t[200005],shu[200005],check[100005];
int main()
{
int n,k=0,f=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>t[i];
}
sort(t,t+n);
for(int i=1;i<n;i++)
{
if(i==1)
{
if(t[0]==t[1])
{
shu[0]=t[0];
check[0]+=2;
}
else
{
shu[0]=t[0];
shu[1]=t[1];
check[0]=1;
k++;
f++;
}
}
else
{
if(t[i]==t[i+1])
{
shu[k]=t[i];
check[f]++;
}
else
{
shu[k]=t[i];
check[f]++;
k++;
f++;
}
}
}
for(int i=0;i<k;i++)
{
cout<<shu[i]<<" "<<check[i]<<endl;
}
}