#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt; cin >> tt; while (tt--) { int n; cin >> n; vector a(n); for (int &x : a) { cin >> x; } sort(a.begin(), a.end()); vector pre(n + 1); for (int i = 0; i < n; i++) { pre[i + 1] = pre[i] + a[i]; } long long ans = 0; for (int i = 0; i < n; i++) { ans += (i + 0ll) * a[i] - pre[i]; } cout << ans << '\n'; } return 0; }