CF1968C.Assembly via Remainders

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Assembly via Remainders

You are given an array x2,x3,…,xnx_2,x_3,\dots,x_n. Your task is to find any array a1,…,ana_1,\dots,a_n, where:

  • 1≤ai≤1091\le a_i\le 10^9 for all 1≤i≤n1\le i\le n.
  • xi=ai mod ai−1x_i=a_i \bmod a_{i-1} for all 2≤i≤n2\le i\le n.

Here c mod dc\bmod d denotes the remainder of the division of the integer cc by the integer dd. For example 5 mod 2=15 \bmod 2 = 1, 72 mod 3=072 \bmod 3 = 0, 143 mod 14=3143 \bmod 14 = 3.

Note that if there is more than one aa which satisfies the statement, you are allowed to find any.

Input

The first line contains a single integer tt (1≤t≤104)(1\le t\le 10^4) — the number of test cases.

The first line of each test case contains a single integer nn (2≤n≤500)(2\le n\le 500) — the number of elements in aa.

The second line of each test case contains n−1n-1 integers x2,…,xnx_2,\dots,x_n (1≤xi≤500)(1\le x_i\le 500) — the elements of xx.

It is guaranteed that the sum of values nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

Output

For each test case output any a1,…,ana_1,\dots,a_n (1≤ai≤1091 \le a_i \le 10^9) which satisfies the statement.

Note

In the first test case a=[3,5,4,9]a=[3,5,4,9] satisfies the conditions, because:

  • a2 mod a1=5 mod 3=2=x2a_2\bmod a_1=5\bmod 3=2=x_2;
  • a3 mod a2=4 mod 5=4=x3a_3\bmod a_2=4\bmod 5=4=x_3;
  • a4 mod a3=9 mod 4=1=x4a_4\bmod a_3=9\bmod 4=1=x_4;

Samples

5
4
2 4 1
3
1 1
6
4 2 5 1 2
2
500
3
1 5
3 5 4 9
2 5 11
5 14 16 5 11 24
501 500
2 7 5

在线编程 IDE

建议全屏模式获得最佳体验