//平分硬币问题
//对sum/2进行01背包,sum-2*dp[sum/2]
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std; int value[],dp[]; int main()
{
int n,m,sum,sum1;
cin>>n;
while(n--)
{
cin>>m;
sum=;
for(int i=;i<=m;i++)
{
cin>>value[i];
sum+=value[i];
}
sum1=sum/;
memset(dp,,sizeof(dp));
for(int i=;i<=m;i++)
for(int j=sum1;j>=value[i];j--)
dp[j]=max(dp[j],dp[j-value[i]]+value[i]);
cout<<sum-*dp[sum1]<<endl;
}
return ;
}