#K92332. Maximum Absolute Difference between Even and Odd Indexed Sums

    ID: 38174 Type: Default 1000ms 256MiB

Maximum Absolute Difference between Even and Odd Indexed Sums

Maximum Absolute Difference between Even and Odd Indexed Sums

Given T test cases, each test case consists of an integer N followed by a sequence of N integers. For each test case, compute the absolute difference between the sum of the elements at even indices and the sum of the elements at odd indices (using 0-based indexing).

Mathematically, if \(S_{even} = \sum_{\substack{i=0 \\ i \; even}}^{N-1} a_i\) and \(S_{odd} = \sum_{\substack{i=0 \\ i \; odd}}^{N-1} a_i\), then the answer for that test case is given by \(|S_{even} - S_{odd}|\>.

inputFormat

The input begins with an integer T (the number of test cases). Each test case consists of two lines. The first line contains an integer N denoting the number of elements. The second line contains N space-separated integers.

outputFormat

For each test case, output a single line containing the absolute difference between the sum of elements at even indices and the sum of elements at odd indices.

## sample
2
5
1 2 3 4 5
4
1 -1 1 -1
3

4

</p>