Square
#include <bits/stdc++.h>
using namespace std;
int n;
bool ok;
const int max_n = 25;
int lens[max_n];
int used[max_n];
int target;
void dfs(int idx, int cur, int pos) {//idx:当前拼到了第idx根, cur:当前根的长度,n:从n号棍子开始找
if(idx > 3 ) {//所有边找到了
ok = true;
return;
}
for(int i = pos; i >= 1; i--) {
if(used[i] == 1) {//已经用掉了
continue;
}
if(lens[i] == lens[i+1] && used[i+1] == 0) {//同长度木棍,前面已经试过,不可能
continue;
}
if(cur + lens[i] <= target) {
used[i] = 1;//用掉它
if(cur + lens[i] == target) {//又找出1条边
dfs(idx+1, 0, n);
} else if(cur + lens[i] < target) {
dfs(idx, cur + lens[i], i - 1);//用它,但不能构成1条边
}
if(ok) {//已经都搞定了,不用回溯
return;
}
used[i] = 0;//不用它
}
}
}
int main() {
//freopen("data.in", "r", stdin);
int No;
scanf("%d", &No);
for(int j = 0; j < No; ++j) {
memset(lens, -1, sizeof(lens));
memset(used, 0, sizeof(used));
target = 0;
scanf("%d", &n);
int sum = 0;
for(int i = 1; i <= n; ++i) {
scanf("%d", &lens[i]);
sum += lens[i];
}
if(sum % 4 != 0) { //不可能搞出来,提前退出
printf("no\n");
continue;
}
sort(lens+1, lens+n+1);
target = sum/4;//每条边的长度
ok = false;
dfs(0, 0, n);
if(ok)
printf("yes\n");
else
printf("no\n");
}
return 0;
}