#include <bits/stdc++.h>
        using namespace std;
        #define pb push_back
        #define mk make_pair
        #define ff first
        #define ss second
        typedef long long ll;
        //const int mod = 1e9 + 7;
        
        
        int main(){
		int t;
		cin>>t;
		while(t--){
			int n;
			cin>>n;
			ll ans=0;
			ll a[n];
			for(int i=0;i<n;i++)scanf("%lld",&a[i]);
			sort(a,a+n);
			ll tr = 0,ans2=0;
			for(int i=1;i<n;i++){
				if(i>1){
					ans2=0;
					ans2 -= ((a[i]-a[i-1])*(i-2) + (a[i]-a[i-2]) + tr);
					
					tr = -ans2;
					ans+=ans2;
					}
				}
				
				
			cout<<ans<<endl;
			}
		
		
		return 0;
    	}
