#include using namespace std; typedef long long ll; int a[100005];ll ans,now; int read(){ int res=0,op=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')op=-1;ch=getchar();} while(isdigit(ch))res=res*10+ch-'0',ch=getchar(); return res*op; } void write(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+48); } void solve(){ int n=read(); for(int i=1;i<=n;i++)a[i]=read(); sort(a+1,a+n+1); now=0;ans=0; for(int i=1;i<=n;i++){ now+=a[i],ans+=(ll)a[i]*i-now; } write(ans);puts(""); } int main() { int es=read(); while(es--) solve(); return 0; }