#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define N 100010
#define ll long long
using namespace std;
int T, n, d[N];
void doit()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &d[i]);
    sort(d + 1, d + n + 1);
    ll ans = d[n];
    for (int i = 1; i <= n; i++)
        ans += (ll)((n - i) - (i - 1)) * d[i];
    printf("%lld\n", ans);
}
int main()
{
    cin >> T;
    while (T--)
        doit();
}