#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<long long>

using namespace std;

typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vll d(n), pref(n+1);
        for (int i = 0; i < n; ++i) {
            cin >> d[i];
        }
        sort(d.begin(), d.end());
        for(int i = n-1; i >= 0; i--){
            pref[i] = pref[i+1] - d[i];
        }
        ll res = 0;
        for(int i = 0; i < n-1; i++){
            res += (n-i-1) * d[i] + pref[i+1];
        }
        cout << res + d[n-1]<< '\n';
    }
    return 0;
}
