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