#include using namespace std; void solve() { int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } sort(begin(A), end(A)); vector cumA(N + 1, 0); for (int i = 0; i < N; ++i) { cumA[i + 1] = A[i] * (i % 2 == 0 ? 1 : -1) + cumA[i]; } int64_t ans = 0; for (int l = 0, r = N; l < r; ++l, --r) { ans = max(ans, abs(cumA[r] - cumA[l])); } cout << ans << endl; } int main() { int T; cin >> T; for (int i = 0; i < T; ++i) { solve(); } }