#include <stdio.h>
int calculateMaxScore(int N, int* arr) {
int count1 = 0, count_minus1 = 0, count0 = 0;
for (int i = 0; i < N; i++) {
if (arr[i] == 1) count1++;
else if (arr[i] == -1) count_minus1++;
else count0++;
}
int score = 0;
// Use pairs of -1s and one 1 to get a score of 1
while (count_minus1 >= 2 && count1 >= 1) {
score += 1;
count_minus1 -= 2;
count1 -= 1;
}
// Use three 1s to get a score of 1
while (count1 >= 3) {
score += 1;
count1 -= 3;
}
// Use three -1s to get a score of -1
while (count_minus1 >= 3) {
score -= 1;
count_minus1 -= 3;
}
// Handle any remaining combinations
while (count0 >= 1 && (count1 >= 2 || count_minus1 >= 2)) {
score += 0;
count0 -= 1;
if (count1 >= 2) {
count1 -= 2;
} else if (count_minus1 >= 2) {
count_minus1 -= 2;
}
}
return score;
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int N;
scanf("%d", &N);
int arr[N];
for (int i = 0; i < N; i++) {
scanf("%d", &arr[i]);
}
printf("%d\n", calculateMaxScore(N, arr));
}
return 0;
}