#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
using ll = long long;
void solve() {
int n; cin >> n;
map<int, int> mp;
for(int i=0; i<n; i++) {
int e; cin >> e;
mp[e]++;
}
int one_ct = mp[1] , m_ct = mp[-1] , z_ct = mp[0] % 3;
// cout << one_ct << ' ' << m_ct << ' ' << z_ct << endl;
int s = 0;
if(z_ct > 0 && m_ct == 0 && z_ct == 0) {
cout << s << endl;
return;
}
while(one_ct >= 1 && m_ct >= 2) {
m_ct -= 2;
one_ct -= 1;
s += 1;
}
if(m_ct == 1) {
if(z_ct == 0) s-= 1;
cout << s << endl;
return;
}
if(m_ct == 0) {
if(z_ct) s -= 1;
cout << s << endl;
return;
}
if(one_ct == 0) {
if(z_ct == 1) m_ct -= 2;
if(z_ct == 2) m_ct -= 1;
s += -1 * (m_ct / 3);
cout << s << endl;
return;
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}