#include <bits/stdc++.h>
using namespace std;
#define ll long long
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int dx2[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dy2[] = {0, 0, 1, -1, 1, 1, -1, -1};
int knightX[] = {-2, -2, 2, 2, 1, 1, -1, -1};
int knightY[] = {-1, 1, -1, 1, -2, 2, -2, 2};
const ll INF = 0x3f3f3f3f;
const int N = 1e6 + 5, K = 105;
const ll MOD = 1e9 + 7;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
int n;
cin >> n;
int cnt = 0, z = 0, o = 0;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
cnt += x == -1;
z += x == 0;
o += x == 1;
}
int ans = o / 3;
o %= 3;
int x = min(cnt / 2, o);
ans += x;
cnt -= 2 * x;
ans -= cnt / 3;
cout << ans << endl;
}
return 0;
}