#C14945. Array Compression

    ID: 44650 Type: Default 1000ms 256MiB

Array Compression

Array Compression

You are given an array of integers. Your task is to compress the array by replacing each group of consecutive equal elements with the element followed by the count of its repetitions. If the resulting compressed array is not strictly shorter than the original array, then output the original array instead.

For example, consider the array [1, 1, 2, 3, 3, 3, 4]. The consecutive group of 1's becomes [1, 2] and the group of 3's becomes [3, 3]. Thus, the array compresses to [1, 2, 2, 3, 3, 4].

Note: If a count has more than one digit, each digit is placed as a separate element in the compressed array. For instance, a group of 12 consecutive elements would be represented as the element followed by 1 and 2.

This problem requires careful implementation of in-place compression logic, and is typical of a hard level coding competition problem.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer N representing the number of elements in the array. The second line contains N space-separated integers.

outputFormat

Output the final array (after compression, if it helped reduce the length) as space-separated integers on a single line to standard output (stdout).

## sample
1
1
1