CF1731A.Joey Takes Money

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Joey Takes Money

Joey is low on money. His friend Chandler wants to lend Joey some money, but can't give him directly, as Joey is too proud of himself to accept it. So, in order to trick him, Chandler asks Joey to play a game.

In this game, Chandler gives Joey an array a1,a2,,ana_1, a_2, \dots, a_n (n2n \geq 2) of positive integers (ai1a_i \ge 1).

Joey can perform the following operation on the array any number of times:

  1. Take two indices ii and jj (1i<jn)1 \le i \lt j \le n).
  2. Choose two integers xx and yy (x,y1x, y \ge 1) such that xy=aiajx \cdot y = a_i \cdot a_j.
  3. Replace aia_i by xx and aja_j by yy.

In the end, Joey will get the money equal to the sum of elements of the final array.

Find the maximum amount of money ans\mathrm{ans} Joey can get but print 2022ans2022 \cdot \mathrm{ans}. Why multiplied by 20222022? Because we are never gonna see it again!

It is guaranteed that the product of all the elements of the array aa doesn't exceed 101210^{12}.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t40001 \leq t \leq 4000). Description of the test cases follows.

The first line of each test case contains a single integer nn (2n502 \leq n \leq 50) — the length of the array aa.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1061 \leq a_i \leq 10^6) — the array itself.

It's guaranteed that the product of all aia_i doesn't exceed 101210^{12} (i. e. a1a2an1012a_1 \cdot a_2 \cdot \ldots \cdot a_n \le 10^{12}).

Output

For each test case, print the maximum money Joey can get multiplied by 20222022.

Note

In the first test case, Joey can do the following:

  1. He chooses i=1i = 1 and j=2j = 2 (so he has a[i]a[j]=6a[i] \cdot a[j] = 6), chooses x=6x = 6 and y=1y = 1 and makes a[i]=6a[i] = 6 and a[j]=1a[j] = 1. $$[2, 3, 2] \xrightarrow[x = 6,; y = 1]{i = 1,; j = 2} [6, 1, 2]$$
  2. He choosesi=1i = 1andj=3j = 3(so he hasa[i]a[j]=12a[i] \cdot a[j] = 12), choosesx=12x = 12andy=1y = 1and makesa[i]=12a[i] = 12anda[j]=1a[j] = 1.$$[6, 1, 2] \xrightarrow[x = 12,; y = 1]{i = 1,; j = 3} [12, 1, 1]$$
The sum is1414which is the maximum of all possible sums. The answer is202214=283082022 \cdot 14 = 28308.</li> </ol>

Samples

3
3
2 3 2
2
1 3
3
1000000 1000000 1
28308
8088
2022000000004044

在线编程 IDE

建议全屏模式获得最佳体验