#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pairs;

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