Juku keeps track of his expenses in a text file with the following format. The hierarchy is not always exactly three levels deep.
March expenses - 1000
Food - 500
Curd snacks - 250
Meat - 250
Fun - 400
Party - 200
Cinema - 200
Health - 100
While re-saving the file, his text editor somehow lost all of the indentation, and now the file looks like this.
March expenses - 1000
Food - 500
Curd snacks - 250
Meat - 250
Fun - 400
Party - 200
Cinema - 200
Health - 100
Given that the first line of the file is the total of all expenses, write a program that helps Juku restore the original hierarchy.
Formally, the amount on each line equals the sum of the amounts of the items nested exactly one level directly beneath it (its immediate children). The amounts are given in file order (a pre-order traversal of the hierarchy), and you must recover the indentation depth of each line.
The first line contains the number of lines $N$ ($1 \le N \le 20$). Each of the next $N$ lines contains one amount $A_i$ ($1 \le A_i \le 10^9$), in file order.
Print exactly $N$ lines. On line $i$, print the indentation depth of the $i$-th amount from the input (depth is 0-based). The first line's depth is always $0$, and when $N \ge 2$ the second line's depth is always $1$.
A depth assignment is valid when it forms a single hierarchy rooted at the first line and, for every line that is split into sub-items, the amounts of its immediate children sum exactly to that line's amount.
Because several valid indentations may exist, print the lexicographically smallest valid sequence of depths $d_1, d_2, \dots, d_N$ (compare the sequences element by element and choose the one whose first differing position holds the smaller value).