#include <bits/stdc++.h>
using namespace std;
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(NULL);           \
    cout.tie(NULL);
#define int long long
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define endl '\n'
#define pi 3.141592653589793238
#define mp make_pair
#define pb push_back
#define precise cout << fixed << setprecision(20)
#define ff first
#define ss second
#define uniq(v) v.resize(distance(v.begin(), unique(all(v))))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vvi vector<vector<int>>
#define deb(x) cerr << #x << ' ' << '=' << ' ' << x << '\n'
const int mod = 1e9 + 7;
const int INF = 1e12;
const int MAXN = 300005;
template <typename T>
istream &operator>>(istream &in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &v)
{
    for (T &x : v)
        out << x << " ";
    return out;
}
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int max(int a, int b)
{
    if (a > b)
        return a;
    else
        return b;
}
int power(int a, int b)
{
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int gcd(int p, int q)
{
    if (p % q == 0)
        return q;
    else
    {
        return gcd(q, p % q);
    }
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
int sub(int a, int b) { return (((a - b) % mod) + mod) % mod; }
struct node
{
    int data;
    struct node *left;
    struct node *right;
};

node *new_node(int val)
{
    node *x = (node *)malloc(sizeof(node));
    x->data = val;
    x->left = x->right = NULL;
    return x;
}

int height(node *root)
{
    if (root == NULL)
        return 0;
    else
        return 1 + max(height(root->left), height(root->right));
}

int diameter(node *root, int *Height)
{
    if (root == NULL)
    {
        return 0;
        *Height = 0;
    }
    int l = 0, r = 0, ldia, rdia;

    ldia = diameter(root->left, &l);
    rdia = diameter(root->right, &r);

    *Height = max(l, r) + 1;

    return max(1 + l + r, max(ldia, rdia));
}
node *insert_new_node(node *root, int data)
{
    if (root == NULL)
        return new_node(data);

    else
    {
        if (data <= root->data)
            root->left = insert_new_node(root->left, data);
        else
            root->right = insert_new_node(root->right, data);

        return root;
    }
}
void Pre_order(node *root)
{
    if (root)
    {
        cout << root->data << endl;
        Pre_order(root->left);
        Pre_order(root->right);
    }
}
node *Search(node *root, int k)
{
    if (root->data == k)
        return root;
    else if (root->data > k)
        return Search(root->left, k);
    else
        return Search(root->right, k);
}
int n, m;
vector<pair<int, int>> adj[100001];
bool visited[100001], sptset[100001];
int dist[100001];
void addedge(int a, int b, int w)
{
    adj[a].pb({b, w});
    adj[b].pb({a, w});
}

signed main()
{
    fastio;
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int d[n], dp[n], ans;
        for (int i = 0; i < n; i++)
            cin >> d[i];
        if (n == 1)
        {
            cout << 0 << endl;
            continue;
        }
        sort(d, d + n);
        ans = d[n - 1];
        dp[0] = 0;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] - i * (d[i] - d[i - 1]);
            ans += dp[i];
        }

        cout << ans << endl;
    }
}
