#K78777. Maximum Space Credits
Maximum Space Credits
Maximum Space Credits
You are given several trade sequences. Each sequence consists of an integer N and N space-separated integers that represent trade values which can either contribute credits (positive numbers) or deduct credits (negative numbers).
Your task is to process each trade sequence and calculate the total credits obtained by summing the trades in the given order as well as the reverse order. Although mathematically the sum remains the same because addition is commutative, the purpose of the problem is to verify proper handling of input order and arithmetic operations.
The total credits S for a sequence is computed as:
\( S = \sum_{i=1}^{N} a_i \)
For each test case, output the maximum of the two computed sums (i.e. \( \max(S, S) \) which is equivalent to \( S \) in this problem).
inputFormat
The input is given via standard input (stdin). The first line contains an integer T representing the number of test cases. For each test case, the first line contains an integer N indicating the number of trades. The following line contains N space-separated integers representing the trade values.
outputFormat
For each test case, print a single line on standard output (stdout) containing the maximum total space credits obtainable from that sequence.## sample
2
4
5 -3 12 -7
3
1 2 3
7
6
</p>