#include #include #include #include #include #include using namespace std; template inline void R(Type &x) { int c = getchar(); bool neg = 0; for (; c < 48 || c > 57; c = getchar())if (c == '-')neg = true; for (x = 0; c > 47 && c < 58; x = (Type) 10 * x + c - 48, c = getchar()); if (neg)x = -x; } long long ans, a[100010]; int n; int main() { int T; R(T); while (T--) { ans = 0; R(n); for (int i = 1; i <= n; ++i) R(a[i]); sort(a + 1, a + 1 + n); int m = n - 1; for (int i = 1; i <= n; ++i) { ans -= m * a[i]; m -= 2; } printf("%lld\n", ans); } return 0; }