#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tt; cin >> tt;
while (tt--) {
int n, y; cin >> n;
map<int, int> mp;
for (int i = -1; i < 2; i++) mp[i] = 0;
for (int i = 0; i < n; i++) {
cin >> y;
mp[y]++;
}
int zero = mp[0], one = mp[1], minus_one = mp[-1];
int sum1 = (one / 3) - (minus_one / 3);
int oneLeft = one % 3;
int minusLeft = minus_one % 3;
if (minusLeft == 2 && oneLeft != 0) sum1++;
else if (minusLeft == 1 && zero == 0) sum1--;
int sum2 = 0;
if (one >= minus_one / 2) {
sum2 += minus_one / 2;
minusLeft = minus_one % 2;
one -= sum2;
}
else {
sum2 += one;
minusLeft = minus_one - one;
one = 0;
}
if (one >= 3) {
sum2 += one / 3;
oneLeft %= 3;
}
if (minusLeft) {
if (zero == 0) sum2 -= minusLeft;
}
cout << max(sum1, sum2) << '\n';
}
return 0;
}