#include using namespace std; #define il inline #define rg register #define int long long il int read() { int re=0,k=1;char ch=getchar(); while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();} while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();} return re*k; } il void write(int x) { if(x<0)return putchar('-'),write(-x),void(); if(x<10)return putchar(x+48),void(); return write(x/10),write(x%10),void(); } int n,a[100005],s[100005],sum,ans; signed main() { int T=read(); while(T--) { ans=0; int n=read(); for(int i=1;i<=n;i++) sum+=a[i]=read(); sort(a+1,a+n+1); for(int i=1;i<=n;i++) { ans+=sum-a[i]*(n-i+1); sum-=a[i]; } write(ans);puts(""); } }