eolymp
bolt
Try our new interface for solving problems
Problems

Archiving

Archiving

RLE compression algorithm is designed on the following principle. A file is considered as a sequence of bits. Continuous chain of ones and zeros are replaced with the number - the length of the chain, the maximum length is limited to \textbf{K} (a very long chains are broken down into a few and they are encoded by several numbers, among which are inserted zeros). Just for the uniqueness of the first chain is always a chain of zeros (if the sequence begins with \textbf{1}, the first number is written under compression \textbf{0}). \InputFile The first line contains the number of \textbf{K} (\textbf{1} ≤ \textbf{K} ≤ \textbf{1000}). In the second line are given a sequence of ones and zeros at the end of which is number \textbf{2}. The length of the sequence - a natural number not exceeding \textbf{10^6}. \OutputFile The condensed sequence (see examples).
Time limit 1 second
Memory limit 64 MiB
Input example #1
10
0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 2
Output example #1
2 5 3 7