A VInt (Variable Integer) is an integer encoding that allows one to store non-negative integers of variable length. A VInt is stored as a sequence of bytes where each byte is of the following format:
The first bit of each byte is 0
if this is the last byte of the VInt, or 1
otherwise.
The remaining seven bytes contain part of the binary representation of the VInt.
So for example, the binary number:
Can be represented as the following VInt:
VInts are often used for storing integer arrays where most of the entries are small as VInts are shorter than regular 4-byte integers for numbers less than .
Given the bytes representing a series of VInts, can you extract the original array?
Input Specification
The first line of input contains an integer , the number of bytes in the array. The next line contains a string of length representing the sequence of bytes in binary. Each VInt is guaranteed to be at most 4 bytes long.
Output Specification
Output a space-separated list of the decimal integers encoded by the VInts.
Sample Input 1
2
1010100100001000
Sample Output 1
5256
Sample Input 2
4
00001000000000011000111101100011
Sample Output 2
8 1 2019
Comments