#C5617. Taco Folding Array
Taco Folding Array
Taco Folding Array
This problem asks you to fold an array in a specific manner. Given an array \( A = [a_1, a_2, \ldots, a_N] \) of \( N \) integers, you need to repeatedly fold the array by adding together the first and the last elements, the second and the second last, and so on. Formally, after one fold the new array \( B \) is defined as:
\( B_i = \begin{cases} a_i + a_{N-i+1} & \text{if } i \neq N-i+1, \\ a_i & \text{if } i = N-i+1, \end{cases} \) for \( 1 \leq i \leq \lceil \frac{N}{2} \rceil \).
This folding process continues until only one element remains. Your task is to compute this final element for each test case.
inputFormat
The input starts with a single integer \( T \) denoting the number of test cases. For each test case, the first line contains an integer \( N \) representing the number of elements in the array. The next line contains \( N \) space-separated integers that form the array.
outputFormat
For each test case, output a single integer which is the final folded value of the array. Each result should be printed on its own line.
## sample2
5
1 2 3 4 5
4
-1 -2 -3 -4
15
-10
</p>