#K7371. Maximum Product Partition

    ID: 34036 Type: Default 1000ms 256MiB

Maximum Product Partition

Maximum Product Partition

You are given an array of integers. Your task is to partition the array into two non-empty contiguous subarrays such that the product of the sum of the elements in the first subarray and the sum of the elements in the second subarray is as large as possible.

Let \(S_1\) be the sum of the first subarray and \(S_2\) be the sum of the second subarray. The goal is to maximize \(S_1 \times S_2\). The array is guaranteed to have at least two elements.

Example:
For the array [1, 2, 3, 4, 5], one optimal partition is between 3 and 4, where \(S_1 = 1+2+3 = 6\) and \(S_2 = 4+5 = 9\), giving a product of \(6 \times 9 = 54\).

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N_1
a1 a2 ... aN1
N_2
b1 b2 ... bN2
...
N_T
...

Here, T represents the number of test cases. For each test case, the first line contains an integer N, the size of the array, and the next line contains N space-separated integers.

outputFormat

For each test case, output the maximum product of the sums of the two partitions. Each result should be printed on its own line to the standard output (stdout).

## sample
1
5
1 2 3 4 5
54

</p>