#include <bits/stdc++.h>
using namespace std;
const int MAX = int(2e5);
const int RND = 853846273;
long long A[MAX + 5], dp[MAX + 5];
long long solve(int turn, int n)
{
if (turn == n)
return 0;
int pos = turn;
if (dp[pos] != RND)
return dp[pos];
long long res = 0;
if (turn % 2 == 0)
res = max(0LL, A[pos] + solve(turn + 1, n));
else
res = min(0LL, solve(turn + 1, n) - A[pos]);
return dp[pos] = res;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> A[i];
dp[i] = RND;
}
sort (A, A + n, greater<>());
long long res = A[0] - A[1] + solve(2, n);
cout << res << "\n";
}
return 0;
}