题目描述
Read problems statements in Mandarin Chinese and Russian as well.
Special Sum of 4 numbers (a, b, c, d) is defined as:
|a+b-c-d| + |a+c-b-d| + |a+d-b-c| + |c+d-a-b| + |b+d-a-c| + |b+c-a-d|
where |x| denotes absolute value of x.
Read problems statements in Mandarin Chinese and Russian as well.
Special Sum of 4 numbers (a, b, c, d) is defined as:
|a+b-c-d| + |a+c-b-d| + |a+d-b-c| + |c+d-a-b| + |b+d-a-c| + |b+c-a-d|
where |x| denotes absolute value of x.
Given an array A of size N, you need to find the sum of Special Sum of numbers taken over all quadruples of different indices of the array.
------ Input ------
First line contains T, the number of test cases to follow.
First line of each test case contains the only integer N.
Second line of each test case contains the array as N space separated integers.
------ Output ------
For each test case output the sum as explained above.
------ Constraints ------
$1 ≤ T ≤ 100$
$4 ≤ N ≤ 1000$
$1 ≤ Elements of the array ≤ 10^{5}$
$1 ≤ Sum of N over all test case ≤ 2000$
----- Sample Input 1 ------
3
4
1 2 3 3
5
1 2 3 4 5
6
9 18 28 23 12 9
----- Sample Output 1 ------
10
76
1176
输入格式
见题面
输出格式
见题面