#include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> A(N);
int count_neg = 0, count_zero = 0, count_pos = 0;
for (int i = 0; i < N; ++i) {
cin >> A[i];
if (A[i] == -1) count_neg++;
else if (A[i] == 0) count_zero++;
else if (A[i] == 1) count_pos++;
}
int score = 0;
int groups_with_neg = min(count_neg / 2, count_pos);
score += groups_with_neg;
count_neg -= groups_with_neg * 2;
count_pos -= groups_with_neg;
score += count_pos / 3;
count_pos %= 3;
if (count_neg > 0 && count_pos >= 2) {
score += -1;
}
cout << score << endl;
}
return 0;
}