#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
#define int long long int
#define ull unsigned long long
#define pb push_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) (x).begin(),(x).end()
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define sz(x) (int)((x).size())
#define fr first
#define sc second
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define ppc  __builtin_popcount
#define ppcll __builtin_popcountll
const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif


    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int dp[n];
        for (int i = 0; i < n; i++) {
            cin >> dp[i];
        }
        sort(dp, dp + n);
        int ans = 0;
        int sum = 0;
        for (int i = 2; i < n; i++) {
            int temp = (dp[i] * (i - 1));
            sum +=  dp[i - 2];
            ans += sum;
            ans -= temp;
        }
        cout << ans << "\n";
    }

}
