// Created on: 2025-01-02 21:55
// Author: Safwan_Ibrahim
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void solve() {
int n; cin >> n;
int cnt1 = 0, cntm1 = 0, cnt0 = 0;
for (int i = 1; i <= n; i++) {
int x; cin >> x;
cnt0 += x == 0; cnt1 += x == 1; cntm1 += x == -1;
}
int ans = 0;
if (cnt1 >= cntm1 / 2) {
cnt1 -= cntm1 / 2;
ans += cntm1 / 2;
ans += cnt1 / 3;
if (cntm1 % 2 == 1 && cnt0 == 0) {
ans--;
}
}
else {
ans += cnt1;
cntm1 -= cnt1 * 2;
if (cnt0 < cntm1 / 2) {
cntm1 -= cnt0 * 2;
ans -= cntm1 / 3;
}
}
cout << ans << endl;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1; cin >> t;
while(t--) solve();
return 0;
}