#include #include #include #include #include #include #include using namespace std; #define ll long long const int maxn = 1e5+10; ll ans; int n; ll a[maxn]; int main() { int t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lld",&a[i]); sort(a+1,a+1+n); ans=0; for(int i=2;i<=n;i++) { ans+=(ll)(i-1)*a[i]-a[i-1]; a[i]+=a[i-1]; } printf("%lld\n",ans); } return 0; }