#include<iostream>
#include<map>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
#include<sstream>
#include<iomanip>
#include<algorithm>
using namespace std;
#define fcio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define debug cout<<"What fuck!!!"<<endl
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e5+10;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll a[maxn];
int main(){
	fcio;
	int T;
	while(cin>>T){
		while(T--){
			int n;
			cin>>n;
			for(int i=1;i<=n;++i)cin>>a[i];
			sort(a+1,a+1+n);
			ll ans=0;
			for(int i=1;i<=n-2;++i){
				ans+=(n-1-i)*(a[n-i+1]-a[i]);
			}
			cout<<-ans<<endl;
		}
	}
	return 0;
}

