Under construction

Still being built. Things may change

Mad Scientist

Interview

Time limit1sMemory limit128 MB

Summary
Recover a non-decreasing sequence of measurements from its cumulative counts P(j), the number of measurements at most j, for each j from 1 to k.
Level

Easy3 of 10

Topics
Array, Prefix sum, Implementation
Solved
No attempts yet

Problem

A mad scientist performed a series of experiments, each consisting of nn phases. During each phase a measurement was taken, yielding a positive integer of magnitude at most kk. Every experiment was designed so that its measurements were monotonically non-decreasing: each measurement is at least as large as all measurements that precede it. For example, one experiment with n=13n = 13 and k=6k = 6 produced the following measurements:

1, 1, 2, 2, 2, 2, 2, 4, 5, 5, 5, 5, 6

Because nn was always larger than kk, the measurement sequence typically contained many repeated values. Being mad, the scientist recorded the data in an unusual way. Instead of storing all nn measurements, the scientist stored a sequence PP of kk values where, for 1≤j≤k1 \le j \le k, P(j)P(j) is the number of phases whose measurement is at most jj. For the experiment above, the measurements were recorded as the PP-sequence:

2, 7, 7, 8, 12, 13

because two measurements are ≤1\le 1, seven are ≤2\le 2, seven are ≤3\le 3, and so on.

The scientist eventually went insane, leaving behind a notebook full of these PP-sequences. Write a program that recovers the original measurements from each PP-sequence.

Input

The input contains several PP-sequences, one per line. Each line begins with the integer kk, the length of the PP-sequence, followed by the kk values of the sequence. The input ends with a line containing a single 00. Every original experiment satisfied 1≤k<n≤261 \le k < n \le 26.

Output

For each PP-sequence, print one line containing the recovered measurements of the original experiment, separated by single spaces.

Examples1

  1. Example 1

    Input
    6 2 7 7 8 12 13
    1 4
    3 4 4 5
    3 0 4 5
    5 2 2 4 7 7
    0
    
    Expected output
    1 1 2 2 2 2 2 4 5 5 5 5 6
    1 1 1 1
    1 1 1 1 3
    2 2 2 2 3
    1 1 3 3 4 4 4