import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class ch1_6_7求解数字排序问题 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
		
		Point a[]=new Point[n];

		for(int i=0;i<n;i++) {
			int k=in.nextInt();
			if(hm.containsKey(k)) {
				hm.put(k, hm.get(k)+1);
			}
			else {
				hm.put(k, 1);
			}
		}
		int s=hm.size();
		int k=0;
		for(java.util.Map.Entry<Integer, Integer> e:hm.entrySet()) {
			a[k]=new Point();
			a[k].b=e.getKey();
			
			a[k++].c=e.getValue();
		
			
		}
		
		Arrays.sort(a,0,s,new Comparator<Point>(){
            public int compare(Point x,Point y){
                return x.c-y.c;
            }
            
        });
		for(int i=s-1;i>=0;i--) {
			System.out.println(a[i].b+" "+a[i].c);
		}
	}

}

class Point{
    
    public int c;
    public int b;
}