ccf-201503-2
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct shu {
int p,q;
};
bool com(shu b,shu c) {
if(b.q==c.q) {
return b.p<c.p;
} else {
return b.q>c.q;
}
}
int main() {
int n,num;
cin>>n;
shu *a=new shu[1001];
for(int i=0; i<1001; i++) {
a[i].p=i;
a[i].q=0;
}
for(int i=0; i<n; i++) {
cin>>num;
a[num].q++;
}
sort(a,a+1001,com);
for(int i=0; i<1001; i++) {
if(a[i].q==0) {
break;
} else {
cout<<a[i].p<<" "<<a[i].q<<endl;
}
}
return 0;
}