#include using namespace std; typedef long long ll; typedef pair PII; const int MAXN = 1e6 + 10; const int MM = 1e9 + 7; int n; ll a[MAXN]; void solve(int casi){ scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); } sort(a + 1, a + n + 1); ll sm = a[1]; ll ans = 0; for (int i = 2; i <= n; i++) { ans += (i - 1) * a[i] - sm; sm += a[i]; } printf("%lld\n", ans); } int main(){ int T = 1; scanf("%d", &T); for (int i = 1; i <= T; i++) solve(i); return 0; }