#include using namespace std; typedef long long ll; typedef unsigned long long ull; #define Rep(i,a,b) for(register int i=(a);i<=(b);++i) #define rep(i,a,b) for(register int i=(a);i<(b);++i) #define Dep(i,a,b) for(register int i=(a);i>=(b);--i) #define mem(x,v) memset(x,v,sizeof(x)) #define gc getchar #define pc putchar inline ll read(){ ll x = 0,f = 0;char c = gc(); for(;!isdigit(c);c=gc()) f|=(c=='-'); for(;isdigit(c);c=gc()) x = x * 10 + (c - '0'); return f ? -x : x; } inline void write(ll x){if(x < 0) pc('-'),x=-x;if(x>=10) write(x / 10);pc(x%10+'0');} inline void writeln(ll x){write(x),pc('\n');} inline void wri(ll x){write(x),pc(' ');} const int maxn = 1e6+233; int a[maxn],n; void solve(){ n = read(); Rep(i,1,n) a[i] = read(); sort(a+1,a+1+n); ll ans = 0; Rep(i,1,n){ ans += 1ll*a[i] * (i-1); ans -= 1ll*a[i] * (n-i); }writeln(ans); } int main(){ int T = read(); while(T--) solve(); return 0; }