#include <bits/stdc++.h>  // Damn ....
using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pq_min priority_queue<int, vector<int>, greater<int>>
typedef long long ll;
typedef long double ld;
const int MOD = 1e9 + 7;
const ll OO = 2e18;
const int oo = 1e9;
const int sz = 1e5+5;
////////////////////////////////////////////////////////////////////////////////////////
int n; int arr[105]; int dp[105][55555];
int go(int i, int val) {
    if (i >= n) return abs(val);;
    if (dp[i][val] != -1)
        return dp[i][val];
    int a= go(i+1,val+arr[i]);
    int b= go(i+1,val-arr[i]);
    return dp[i][val] = min(a, b);
}
//////////////////////////////////////////////////////////////////////////////////////
void _3OMDA() {
    cin>>n;
    for (int i = 0; i < n; i++) cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout << go(0,0) << endl;
}
/////////////////////////////////////////////////////////////////////////////////////
signed main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    cin >> t;
    for (int i = 0; i < t; i++) {
        _3OMDA();
    }
    return 0;
}