#include using namespace std; int t, n, m, p; int a[123123]; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); sort(a + 1, a + n + 1); unsigned long long sum = 0, ans = 0; for (int i = 1; i <= n; ++i) { ans += 1ull * a[i] * (i - 1) - sum; sum += a[i]; } printf("%llu\n", ans); } }