#include using std::cin; using std::cout; typedef long long ll; int n; int a[100054]; void work() { int i; ll ans = 0; cin >> n; for (i = 0; i < n; ++i) cin >> a[i]; std::sort(a, a + n); for (i = 1; i < n; ++i) ans += ll(a[i] - a[i - 1]) * i * (n - i); cout << ans << '\n'; } int main() { int T; std::ios::sync_with_stdio(false), cin.tie(NULL); for (cin >> T; T; --T) work(); return 0; }