#include using namespace std; #define ll long long const int N = 100005; int T, n, a[N]; 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); ll x=0, y=0, ans=0; for(int i=1; i<=n; ++i) ans+=a[i]*y-x, x+=a[i], ++y; printf("%lld\n", ans); } return 0; }