In the Middle Ages, many villages practiced agriculture using the open-field system: each field was divided into many narrow strips of land, each cultivated by a different family.
The government of Utopia has decided to reform agriculture and cultivate each field using modern equipment. To compensate the families of each village, the government has agreed to make a cash payment to each village. The amount of the cash payment is calculated using the procedure described below.
For simplicity, assume that the strips of land are all vertical. Given a field with strips of land, let be the lengths of their borders, where is the length of the left border of strip , and is the length of the right border. Note that the right border of strip is also the left border of strip .
When merging two adjoining strips of land and , the cash payment is , i.e. the product of the lengths of the three borders of and (including the common border that separates them). After merging the two strips of land, they become a single strip whose borders have lengths and .
Your goal is to help the villagers maximize the compensatory cash payment.
The input starts with the number of test cases . For each test case, there is an intenger that represents the number of strips of land in a given field. On the next line, there are numbers describing the lengths of the borders.
For each test case, print the maximum cash payment for the given field on a separate line.
In the first example, there are three strips of land , and . There are two ways to merge the strips: first merge and , and then merge the resulting strip with , or first merge and , and then merge the resulting strip with . The cash payment for the first case is , while the cash payment for the second case is . Hence the second case is optimal.
In the second example, there are four strips of land. The maximum cash payment is achieved by merging with , then merging the result with , and finally merging the result with , resulting in a cash payment of .
Input
2 3 1 4 3 2 4 4 3 2 3 4
Output
32 102