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