 
#include<bits/stdc++.h>
#define fi first
#define se second
#define INF 100000000000000000LL
#define ll  long long 
#define debug(x) cout << #x << " "<< x <<endl; 
#define debug_vector(v) cout << #v << " "; _print(v);
const ll inf =1e9+44;
const int MAX=3e5+9;
const ll MOD= 1e9+7;
const double eps=1e-10;
double const PI=3.1415926535897931;
using namespace std;
int dx[4] = {1 ,0 , - 1, 0};
int dy[4] = {0 ,1 ,  0 , -1};
void _print(vector<int> v){
	cout << "[ ";
	for ( auto u : v)
		cout << u << " ";
	cout << " ]"<< endl;
}
int main(){
	int test;
	cin >> test;

	while (test--){
		int n;
		cin >> n;
		vector < ll> v(n+1);

		vector < ll > pre(n+1);
		pre[0] = 0;
		for (int i = 1; i <= n ; i++)
			cin >> v[i];
		sort(v.begin()+1 , v.end());
		vector < ll > edges(n+1);

		for (int i = 2; i<=n ; i++)
			edges[i] = v[i]-v[i-1];

		for (int i = 2; i <=n; i++)
			pre[i] = (edges[i])*(long long )(i-1) + pre[i-1];

		ll tot = 0;

		for (int i = 2; i <=n; i++)
			tot = tot + edges[i] -pre[i];

		cout << tot << endl;
	}
}
 