#include #include #define RI register int #define int long long int const MAXN = 1e5 + 5; int a[MAXN]; signed main() { int T; scanf("%lld", &T); while (T--) { int n; scanf("%lld", &n); for (RI i = 1; i <= n; ++i) scanf("%lld", &a[i]); std :: sort(a + 1, a + 1 + n); int ans = 0; for (RI i = 1; i <= n; ++i) { ans += a[i] * (i - 1); ans -= a[i] * (n - i); } printf("%lld\n", ans); } return 0; }