# include using namespace std; namespace Base{ # define mr make_pair typedef long long ll; typedef double db; const int inf = 0x3f3f3f3f, INF = 0x7fffffff; const ll infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll; template void read(T &x){ x = 0; int fh = 1; double num = 1.0; char ch = getchar(); while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); } while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); } if (ch == '.'){ ch = getchar(); while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();} } x = x * fh; } template void chmax(T &x, T y){x = x < y ? y : x;} template void chmin(T &x, T y){x = x > y ? y : x;} } using namespace Base; const int N = 100010; int n, a[N], T; ll sum[N], ans; int main(){ read(T); while (T--){ ans = 0; read(n); for (int i = 1; i <= n; i++) read(a[i]); sort(a + 1, a + n + 1); sum[n + 1] = 0; for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i]; for (int i = 1; i <= n; i++) ans = ans + sum[i + 1] - 1ll * a[i] * (n - i); cout << ans << endl; } return 0; }