#include <iostream>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
int neg = 0, zero = 0, pos = 0;
for (int i = 0; i < N; ++i) {
int x;
cin >> x;
if (x == -1) neg++;
else if (x == 0) zero++;
else pos++;
}
int score = 0;
int trip_pos = pos / 3;
score += trip_pos;
pos -= trip_pos * 3;
int trip_neg_pos = min(neg / 2, pos);
score += trip_neg_pos;
neg -= trip_neg_pos * 2;
pos -= trip_neg_pos;
int trip_neg = neg / 3;
score -= trip_neg;
neg -= trip_neg * 3;
cout << score << "\n";
}
return 0;
}