// package csp;
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner cin=new Scanner(new BufferedInputStream(System.in));
int n=cin.nextInt(),mx=-1;
int t[]=new int[10015];
for(int i=0;i<n;i++)
{
int x=cin.nextInt();
t[x]++;
mx=Math.max(mx, x);
}
List<node>list=new ArrayList<>();
for(int i=0;i<=mx;i++)
{
if(t[i]!=0)
{
list.add(new node(i,t[i]));
}
}
Collections.sort(list);
for(int i=0;i<list.size();i++)
{
System.out.println(list.get(i).id+" "+list.get(i).num);
}
}
public static class node implements Comparable<node>{
int id,num;
public node(int id,int num)
{
this.id=id;
this.num=num;
}
// @override
public int compareTo(node a)
{
if(this.num-a.num!=0)
return a.num-this.num;
else return this.id-a.id;
}
}
}