题目描述
During Quarantine Time Chef is at home and he was quite confused about what to cook so, he went to his son and asked about what would he prefer to have? He replied, cakes.
Now, chef cook $N$ number of cake and number of layers for every cake is different. After cakes are baked, Chef arranged them in a particular order and then generates a number by putting number of layers of cakes as digit in sequence (e.g., if chef arranges cakes with layers in sequence $2$, $3$ and $5$ then generated number is $235$).
Chef has to make his son powerful in mathematics, so he called his son and ask him to arrange the cakes in all the possible ways and every time when different sequence is generated he has to note down the number. At the end he has to find sum of all the generated numbers. So, help him to complete this task.
-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- The first line of each test case contains a single integer $N$ denoting number of cakes.
- The second line contains $N$ space-separated integers $L1$ $L2$ … $LN$ layers of the cake.
-----Output:-----
For each test case, print a single line containing sum of all the possible numbers which is generated by arranging cake in different sequence.
-----Constraints :-----
- $1 \leq T \leq 2*10^5$
- $1 \leq N, L1, L2, L3,…, LN \leq 9$
-----Sample Input:-----
1
3
2 3 5
-----Sample Output:-----
2220
-----Explanation:-----
Sum of all possibilities :
$235 + 532 + 253 + 352 + 523 + 325 = 2220 $
输入格式
见题面
输出格式
见题面