#include #include #define MN 200000 typedef long long LL; int n,a[MN+5]; LL ans,tans; void solve(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); std::sort(a+1,a+1+n); tans = ans = 0; for(int i=2;i<=n;i++){ tans += 1ll*(a[i]-a[i-1])*(i-1); ans += tans; } printf("%lld\n",ans); } int main(){ int T; scanf("%d",&T); while(T--) solve(); }