#C13221. Consecutive Integer List Compression

    ID: 42736 Type: Default 1000ms 256MiB

Consecutive Integer List Compression

Consecutive Integer List Compression

You are given a list of integers. Your task is to compress the list by representing each consecutive group of identical integers as a substring of the form \(a*\!n\) where \(a\) is the integer and \(n\) is the count of its consecutive occurrences. The final result is the concatenation of all such substrings with no delimiter.

For example:

  • If the list is empty, the output should be an empty string.
  • If the list is [1], the output should be "1*1".
  • If the list is [2, 2, 2], the output should be "2*3".
  • If the list is [1, 2, 3], the output should be "1*12*13*1" (i.e. "1*1" followed by "2*1" and then "3*1").

Your solution should read the input from standard input (stdin) and write the result to standard output (stdout).

inputFormat

The first line of input contains an integer \(n\) representing the number of elements in the list. If \(n > 0\), the second line contains \(n\) space-separated integers. If \(n = 0\), no further input is provided and the list is considered empty.

outputFormat

Output a single line which is the compressed string obtained by processing the list as described. If the list is empty, output an empty string.

## sample
0