#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n / 2; i++) {
    int t = (a[i] + a[n - 1 - i]) / 2;
    a[n - 1 - i] -= t - a[i];
    a[i] = t;
  }
  sort(a.begin(), a.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += ((n - 1 - i) - i) * a[i];
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
