#include"iostream"
#include"algorithm"
#include"stdlib.h"
using namespace std;
int a[1005]{ 0 }, b[1005] = { 0 };
int main() {
int n;
cin >> n;
//int* a = (int*)malloc(sizeof(int) * n);
//int* b = (int*)malloc(sizeof(int) * n);
int num;
for (int i = 0; i < n; i++) {
cin >> num;
a[num]++;
}
for (int i = 0; i < 1005; i++)
b[i] = a[i];
sort(b, b + 1005);
for (int i = 1004; i >0; i--) {
for(int j=0;j<1005;j++)
if ((a[j] == b[i])&&a[j]!=0) {
cout << j << " " << a[j] << endl;
a[j] = 0;
}
}
return 0;
}