CF2010A.Alternating Sum of Numbers

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

Alternating Sum of Numbers

You are given a sequence of integers. Output the alternating sum of this sequence. In other words, output a1a2+a3a4+a5a_1 - a_2 + a_3 - a_4 + a_5 - \dots. That is, the signs of plus and minus alternate, starting with a plus.

Input

The first line of the test contains one integer tt (1t10001 \le t \le 1000) — the number of test cases. Then follow tt test cases.

The first line of each test case contains one integer nn (1n501 \le n \le 50) — the length of the sequence. The second line of the test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1001 \le a_i \le 100).

Output

Output tt lines. For each test case, output the required alternating sum of the numbers.

Samples

4
4
1 2 3 17
1
100
2
100 100
5
3 1 4 1 5
-15
100
0
10

在线编程 IDE

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