#include #include using namespace std; long long a[109],ans,C[40][40]; int n,T; int main(){ scanf("%d",&T); C[0][0]=1; for (int i=1;i<=n;i++){ C[i][0]=1; for (int j=1;j<=i;j++){ C[i][j]=C[i-1][j]+C[i-1][j-1]; } } while(T--){ scanf("%d",&n); for (int i=1;i<=n;i++){ scanf("%I64d",&a[i]); } sort(a+1,a+1+n); ans=0; for (int i=1;i<=n;i++){ for (int j=0;i+j<=n;j++){ if (j % 2==0) ans+=a[i]*C[n-i][j]; else ans-=a[i]*C[n-i][j]; } } if (ans<0) ans=-ans; printf("%I64d\n",ans); } }