#K64807. Maximize Sum After Reversal

    ID: 32057 Type: Default 1000ms 256MiB

Maximize Sum After Reversal

Maximize Sum After Reversal

You are given a sequence of N integers. You must perform exactly one reversal on a contiguous subarray (which might be as small as a single element). After this reversal operation, you are required to output the maximum possible sum of the entire sequence.

Note that since reversing any subarray does not change the overall sum of the sequence, the answer for each test case is simply the sum of its integers. Formally, if \(a_1, a_2, \ldots, a_N\) is the sequence, then the answer is:

\[ S = \sum_{i=1}^{N} a_i \]

Your task is to compute \(S\) for each given test case.

inputFormat

The first line contains an integer T, the number of test cases. For each test case, the first line contains an integer N representing the number of elements. The next line contains N space-separated integers representing the sequence.

For example:

6
4
1 2 3 4
3
4 3 5
5
5 4 3 2 1
3
1 1 1
4
1 2 1 2
3
10 20 30

outputFormat

For each test case, output one line containing a single integer, which is the maximum sum of the sequence after performing exactly one reversal operation.

Since the reversal does not alter the total sum, the output for each test case will be equal to the sum of its elements.

## sample
6
4
1 2 3 4
3
4 3 5
5
5 4 3 2 1
3
1 1 1
4
1 2 1 2
3
10 20 30
10

12 15 3 6 60

</p>