#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
#define ll long long
using namespace std;

ll D[111111];

int main() {
    int T;
    cin>>T;
    for(int t=1;t<=T;t++) {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++) {
            cin>>D[i];
        }
        sort(D+1,D+n+1);
        ll S = 0;
        ll ans = 0;
        for(int i=2;i<=n;i++) {
            ans += D[i]-D[i-1]+S-(ll)(i-1)*D[i];
            S+=D[i];
        }
        cout << ans << endl;
    }
}
