#include <bits/stdc++.h>
#include <utility>
using namespace std;
#define int long long
#define fi(i,n) for(int i=0;i<n;i++)
#define f(i, a, b) for(int i=a;i<b;i++)
#define vi vector<int>
#define pb push_back
#define all(x)(x).begin(), (x).end()
#define MOD 1000000007
#define mod 998244353
#define pii pair<int, int>
#define ff first
#define ss second
#define setzero(a) memset(a,0,sizeof(a))
#define prDouble(x) cout<<fixed<<setprecision(10)<<x;
#define SetBits(x) __builtin_popcount(x)
#define eps 0.000001
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define INF 1e18
#define disp(vec, n) fi(i, n) cout << vec[i] << " ";
void kick(int t) { cout << "Case #" << t << ": "; }
bool valid(int i,int j,int n,int m)
{
    return i >= 0 && i < n && j >= 0 && j < m;
}
bool perfect_square(int a)
{
    int num = sqrt(a);
    if(num*num==a)return true;
    return false;
}
int digits(int n)
{
    int cnt = 0;
    while(n>0)
    {
        cnt++;
        n = n/10;
    }
    return cnt;
}
int modularExponentiation(int x,int n)
{
    int result = 1;
    while(n>0)
    {
        if(n % 2 ==1)
        {
            result = ((result%MOD)*(x%MOD))%MOD;
        }
        x  = ((x%MOD)*(x%MOD))%MOD;
        n = n/2;
    }
    return result%MOD;
}
void solve()
{
    int n;
    cin>>n;
    int arr[n];
    fi(i,n){cin>>arr[i];}
    sort(arr,arr+n);
    int p = 0;
    int q = 0;
    fi(i,n)
    {
        p += q - i*arr[i];
        if(i)p += arr[i] - arr[i-1];
        else p += arr[i];
        q += arr[i];
    }
    cout<<p<<endl;


}
int32_t main()
{
    IOS;
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}