#B4115. Sequence Sum Reduction

    ID: 11772 Type: Default 1000ms 256MiB

Sequence Sum Reduction

Sequence Sum Reduction

Given an initial sequence \( A = [A_1, A_2, \ldots, A_N] \) of length \( N \), you are to perform exactly \( N-1 \) operations. In each operation, construct a new sequence \( B \) where for every valid index \( i \) (i.e., \( 1 \le i \le |A|-1 \)), compute:

\( B_i = A_i + A_{i+1} \)

After computing \( B \), erase the old sequence and set \( A = B \). Print the resulting sequence after each operation. Note that after every operation the sequence length decreases by one, and after \( N-1 \) operations, the sequence will have a single number.

inputFormat

The first line contains a single integer \( N \) (\( 2 \le N \le 10^5 \)), representing the length of the sequence. The second line contains \( N \) space-separated integers \( A_1, A_2, \ldots, A_N \) (each absolute value up to \( 10^9 \)).

outputFormat

Output \( N-1 \) lines. Each line should contain the current sequence after each operation. The elements in the sequence should be separated by a single space.

sample

4
1 2 3 4
3 5 7

8 12 20

</p>