#include <iostream>
#include <vector>
using namespace std;
int solve(int n, vector<int>& A) {
int a = 0, b = 0, c = 0;
for (int x : A) {
if (x == -1) a++;
else if (x == 0) b++;
else c++;
}
int score = 0;
int t1 = c / 3;
score += t1;
c %= 3;
int t2 = min(c / 2, a);
score -= t2;
c -= t2 * 2;
a -= t2;
int t3 = a / 3;
score -= t3;
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;
}