#P1903C. Theofanis' Nightmare
Theofanis' Nightmare
No submission language available for this problem.
Description
Theofanis easily gets obsessed with problems before going to sleep and often has nightmares about them. To deal with his obsession he visited his doctor, Dr. Emix.
In his latest nightmare, he has an array of size and wants to divide it into non-empty subarrays such that every element is in exactly one of the subarrays.
For example, the array can be divided to .
The Cypriot value of such division is equal to where is the number of subarrays that we divided the array into and is the sum of the -th subarray.
The Cypriot value of this division of the array .
Theofanis is wondering what is the maximum Cypriot value of any division of the array.
An array is a subarray of an array if can be obtained from by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.
The first line contains a single integer () — the number of test cases.
Each test case consists of two lines.
The first line of each test case contains a single integer () — the size of the array.
The second line contains integers () — the elements of the array.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print one integer — the maximum Cypriot value of the array .
Input
The first line contains a single integer () — the number of test cases.
Each test case consists of two lines.
The first line of each test case contains a single integer () — the size of the array.
The second line contains integers () — the elements of the array.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print one integer — the maximum Cypriot value of the array .
Note
In the first test case, to get the maximum Cypriot value we divide the array into which gives us:
Similarly, in the second test case we divide the array into which gives us .