#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solve(int n, vector<int>& A) {
int a = 0, b = 0, c = 0;
// Count occurrences of -1, 0, and 1
for (int x : A) {
if (x == -1) a++;
else if (x == 0) b++;
else c++;
}
int score = 0;
// Form triplets of three 1's
score += c / 3;
c %= 3;
// Form triplets of two 1's and one -1
int t2 = min(c / 2, a);
score -= t2;
c -= t2 * 2;
a -= t2;
// Form triplets of three -1's
score -= a / 3;
a %= 3;
return score;
}
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
cout << solve(N, A) << endl;
}
return 0;
}