#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main(){
    int T;cin >> T;
    while(T--){
        int n;cin >> n;
        vector<ll>a(n);
        for(int i = 0;i<n;i++)cin >> a[i];
        sort(a.begin(),a.end());
        ll ans = *a.rbegin();
        for(ll i = n-1;i>=1;i--){
            ans-= i*(n-i)*(a[i] - a[i-1]);
        }
        cout << ans << endl;
    }
    // system("pause");
}