LogiQuest

15. Element Frequency

EasyHash MapCounting

Print each distinct value with the number of times it appears, in order of first appearance.

Input format

Line 1: n Line 2: n integers

Output format

One line per distinct value: value count

Example 1

Input

7
3 1 3 2 1 3 4

Output

3 3
1 2
2 1
4 1

Example 2

Input

1
9

Output

9 1

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…