#include <bits/stdc++.h>   #include <string>   #include <algorithm>   #include <vector>   #include <string.h>   #include <stdlib.h>   #include <chrono>   #include <ctime>   using namespace std;   using namespace std::chrono;   typedef long long ll;   #define fast ios_base::sync_with_stdio(false); cin.tie(nullptr)   #define all(v) v.begin(), v.end()   #define vi vector<int>   const int N = 2e6;      void solve() {           int a[N];     long long n;     cin >> n;     for (int i = 0; i < n ; i ++) cin >> a[i];     sort(a, a + n);     long long rlt = a[n - 1];     for (long long i = 1; i < n; i ++) {      long long v = a[i] - a[i - 1];      rlt -= v * i * (n - i);     }     cout << rlt << endl;   }      int main() {    fast;      int t; cin >> t;      while (t--)solve();   }   