#include <iostream>
// #include <bits/stdc++.h>
#include<deque>
#include<algorithm>
#include<math.h>
#include<sstream>
#include<stdio.h>
#include<bitset>
#include<string>
#include<vector>
#include<unordered_map>
#include<queue>
#include<set>
#include<fstream>
#include<map>
#define int long long int
#define ld long double
#define pi 3.1415926535897932384626433832795028841971
#define MOD 1000000007
#define MOD1 998244353
int inf = 1e18;
using namespace std;
int add(long long a, long long b) {return ((a % MOD) + (b % MOD)) % MOD;}
int subtract(long long a, long long b) {return ((a % MOD) - (b % MOD)) % MOD;}
int mult(long long a, long long b) {return ((a % MOD) * (b % MOD)) % MOD;}
int add1(long long a, long long b) {return ((a % MOD1) + (b % MOD1)) % MOD1;}
int subtract1(long long a, long long b) {return ((a % MOD1) - (b % MOD1)) % MOD1;}
int mult1(long long a, long long b) {return ((a % MOD1) * (b % MOD1)) % MOD1;}

int binmodwithMOD1(int a, int b)
{
	int res = 1;
	while (b) {
		if (b & 1) res = mult1(res, a) % MOD1;
		a = mult1(a, a) % MOD1;
		b >>= 1;
	}
	return res;
}

int binmodwithMOD(int a, int b)
{
	int res = 1;
	while (b) {
		if (b & 1) res = mult(res, a) % MOD;
		a = mult(a, a) % MOD;
		b >>= 1;
	}
	return res;
}

int binmodwithoutMOD1orMOD2(int a, int b)
{
	int res = 1;
	while (b) {
		if (b & 1) res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int inverse(int n) {
	return binmodwithMOD(n, MOD - 2);
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int a[n];
		for (int i = 0; i < n; i++) cin >> a[i];
		sort(a, a + n);
		int sum = 0;
		int ans = 0;
		int valneg = 0;
		for (int i = 1; i < n; i++) {
			int diff = -(a[i] - a[i - 1]);
			sum += (diff * i);
			ans += sum;
			valneg += (a[i] - a[i - 1]);
		}
		cout << ans + valneg << "\n";
	}
	return 0;
}