cp/codeforces/19/19txt

94 lines
968 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

A. Alternating Sum of Numbers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given a sequence of integers. Output the alternating sum of this sequence. In other words, output a1a2+a3a4+a5
a
1
a
2
+
a
3
a
4
+
a
5
. That is, the signs of plus and minus alternate, starting with a plus.
Input
The first line of the test contains one integer t
t
(1≤t≤1000
1
t
1000
) — the number of test cases. Then follow t
t
test cases.
The first line of each test case contains one integer n
n
(1≤n≤50
1
n
50
) — the length of the sequence. The second line of the test case contains n
n
integers a1,a2,…,an
a
1
,
a
2
,
,
a
n
(1≤ai≤100
1
a
i
100
).
Output
Output t
t
lines. For each test case, output the required alternating sum of the numbers.
Example
Input
Copy
4
4
1 2 3 17
1
100
2
100 100
5
3 1 4 1 5
Output
Copy
-15
100
0
10