#include #define fo(i,a,b) for(int i=a;i<=b;++i) #define fod(i,a,b) for(int i=a;i>=b;--i) #define max(q,w) ((q)>(w)?(q):(w)) #define min(q,w) ((q)<(w)?(q):(w)) using namespace std; typedef long long LL; const int N=100500,INF=1e9; int read(int &n) { int q=1;n=0;char ch=' '; for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar()); if(ch=='-')q=-1,ch=getchar(); for(;ch<='9'&&ch>='0';ch=getchar())n=(n<<1)+(n<<3)+ch-48; return n; } int n,m; int a[N]; LL ans; int main() { int q,w,_; read(_); while(_--) { read(n); LL t=0; fo(i,1,n)t+=(LL)read(a[i]); sort(a+1,a+1+n); ans=0; fo(i,1,n) { t-=a[i]; ans+=t-(LL)a[i]*(n-i); } printf("%lld\n",ans); } return 0; }