#C9794. Maximizing Crystal Power
Maximizing Crystal Power
Maximizing Crystal Power
Given a sequence of crystals, each with an integer power, you are required to perform a series of operations to maximize the final power. In each operation, you choose two adjacent crystals whose product is the maximum among all adjacent pairs. These two crystals are then combined into a single crystal with power equal to their product. This process is repeated until only one crystal remains.
The combination operation is defined as follows:
\[ a,\ b \rightarrow a \times b \]Your task is to compute the power of the final crystal for each test case.
inputFormat
The input is given via standard input. The first line contains an integer (T) representing the number of test cases. Each test case starts with an integer (N) (the number of crystals) followed by (N) space-separated integers representing the power of each crystal.
outputFormat
For each test case, output a single integer on a new line representing the maximum possible power of the final crystal.## sample
1
2 2 3
6
</p>