#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define N 100005

int main()
{
    fastio;
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll> d(n);
        for(int i=0;i<n;i++) cin>>d[i];
        sort(d.begin(),d.end());
        ll ans=0;
        ll sum=0;
        for(int i=0;i<n;i++){
           ans+=(sum-i*d[i]);
           sum+=d[i];
        }
        cout<<ans+d[n-1]<<endl;
    }
}
