#C12336. Frequency List

    ID: 41752 Type: Default 1000ms 256MiB

Frequency List

Frequency List

Given a list of integers, your task is to compute the frequency of each distinct integer. Let nn be the number of integers and a1,a2,,ana_1, a_2, \dots, a_n be the integers in the list. For every distinct integer, you need to form a tuple (num,freq)(num, freq) where numnum is the integer and freqfreq is its frequency. The output list of tuples must be sorted in descending order by frequency. In the case of ties (i.e. two integers have the same frequency), the tuple with the smaller integer (i.e. smaller numnum) should come first.

inputFormat

The input consists of two lines. The first line contains an integer nn, representing the number of elements in the list. The second line contains nn space-separated integers.

outputFormat

Output the frequency list. Each line should contain two integers separated by a space: the integer and its frequency, in the order specified.## sample

8
4 6 2 4 3 2 6 6
6 3

2 2 4 2 3 1

</p>