/*
* Copyright (c) 2025 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n; cin >> n;
int x,zero=0,one=0,minus=0;
for(int i=0;i<n;i++)
{
cin >> x;
zero += (x==0);
one += (x==1);
minus += (x<0);
}
x = min(one , minus/2);
int ans = x;
one -= x;
minus -= x*2;
x = one/3;
ans += x;
one -= x*3;
if(zero*2 >= minus) cout<<ans<<endl;
else
{
minus -= zero*2;
ans -= minus/3;
if(one==2) --ans;
cout<<ans<<endl;
}
}
int main()
{
int t; cin>> t; while(t--) solve();
}