#C14083. Count Consecutive Occurrences

    ID: 43693 Type: Default 1000ms 256MiB

Count Consecutive Occurrences

Count Consecutive Occurrences

You are given a sequence of integers. Your task is to count the number of consecutive occurrences for each distinct integer group in the sequence and output the result.

For example, given the list

1 1 2 2 2 3 1 1 1

the consecutive groups are: (1, 2), (2, 3), (3, 1), and (1, 3).

The result can be formally expressed as:

$$result = [(a_i, c_i), ...]$$

where a_i is an integer and c_i denotes its consecutive count.

inputFormat

The first line contains a non-negative integer n representing the number of elements in the list. The second line contains n space-separated integers.

If n = 0, then the list is empty.

outputFormat

For each group of consecutive identical integers, output a line with two integers: the integer itself and its consecutive count. The order of groups should follow the input sequence order.

## sample
0