Classical Hard Permutation Problem

Time limit: 1s Memory limit: 256MB Input: Output:

A permutation of length nn is an array pp = [ p1,p2,,pnp_1, p_2, \ldots, p_n ], which contains every integer from 11 to nn (inclusive) and, moreover, each number appears exactly once.

Mr. COACH\mathbb{Mr. \ COACH} gives you the following problem:

Given di=pi+1pid_i = p_{i+1} - p_i for each ii (1in11 \le i \le n-1) can you find the permutation pp?

Input

The first line contains a single integer nn (1n1061 \le n \le 10^6) – the length of the permutation pp

The second line contains n1n-1 integers d1,d2,,dn1d_1, d_2, \ldots, d_{n-1} (di=pi+1pid_i = p_{i+1} - p_i).

Output

Print the hidden permutation pp

Example 1

stdin

3
-1 -1

stdout

3 2 1

Example 2

stdin

5
-3 1 -2 3

stdout

5 2 3 1 4

Log in or sign up to be able to send submissions!