#include <bits/stdc++.h>
using namespace std;
//Speed
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Shoriful cout.tie(NULL);
template<typename T> istream& operator>>(istream& is, vector<T> &v){for (auto& i : v) is >> i; return is;}
template<typename T> ostream& operator<<(ostream& os, vector<T> v){for (auto& i : v) os << i << ' '; return os;}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(v) v.begin(),v.end()
#define rall(v) v.end(),v.begin()
#define fl(i,n) for(int i=0;i<n;i++)
#define rl(i,m,n) for(int i=n;i>=m;i--)
#define py cout<<"YES\n";
#define pn cout<<"NO\n";
#define nl '\n' ;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef map<int,int> mi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<set<int>> vset ;
typedef map<ll,ll> mll;
//code here
void solve(){
int n ; cin >> n ;
vi v(n) ; cin>>v ;
int a= count(all(v),1) ;
int b=count(all(v),0) ;
int c= count(all(v),-1) ;
int ans=0 ;
ans+=(a/3) ;
a%=3;
int d=c/2 ;
int e=min(d,a) ;
ans+=e;
c-=2*e ;
a-=e;
ans-=(c/3) ;
cout<<ans<<nl;
}
int main()
{
Code By Shoriful
// ll t=1 ;
ll t ; cin >> t ;
fl(i,t){
solve() ;
}
return 0;
}