#include <bits/stdc++.h>
using namespace std;
int musa(vector<int>& A)
{
int cnt_n = 0, z = 0, o = 0;
for (int x : A)
{
if (x == -1) cnt_n++;
else if (x == 0) z++;
else if (x == 1) o++;
}
int score = 0;
int tr = o / 3;
score += tr;
o %= 3;
int pn = min(cnt_n / 2, o);
score += pn;
cnt_n -= pn * 2;
o -= pn;
score += (cnt_n / 3) * -1;
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 << musa(A) << endl;
}
return 0;
}