#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
vector <int> FV(600,0);
int lineN, m, fir = 0, sec = 0, temp;
cin >> lineN;
for (int i = 0; i < lineN; i++)
{
cin >> m;
fir = 0; sec = 0;
for (int j = 0; j < m; j++)
cin >> FV[j];
if (m == 0)
{
cout << 0 ;
goto end;
}
if (m == 1)
{
cout << FV[0] ;
goto end;
}
sort(FV.begin(), FV.begin() + m);
if (m == 2)
{
cout << FV[1] - FV[0];
goto end;
}
fir = FV[m - 1];
sec = FV[m - 2] + FV[m - 3];
for (int s = 4; s <= m; s++)
{
if (sec < fir)
sec += FV[m - s];
else
fir += FV[m - s];
}
temp = fir - sec;
if (temp < 0)
temp = temp *-1;
cout << temp;
end:
if (i<lineN-1)
cout << '\n';
}
return 0;
}