#include <bits/stdc++.h>
using namespace std;
#define SC scanf
#define PF printf
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sort_a(a) sort(a.begin(),a.end());
#define sort_d(a) sort(a.rbegin(),a.rend());
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rev(s) reverse(s.begin(),s.end())
#define P(ok) cout << (ok ? "YES\n": "NO\n")
#define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll> PII;
void solve()
{
int n , minusOne = 0 , plusOne = 0 , zero = 0 , x ; cin >> n ; ;
for(int i = 0 ; i < n ; i++) {
cin >> x ;
if(x == 0) zero++ ;
else if(x == 1) plusOne++ ;
else minusOne++ ;
}
if(zero) {
cout << 0 << "\n" ;
return ;
}
int adding = min(minusOne / 2 , plusOne) ;
int deducting = 0 ;
minusOne -= (adding * 2) ;
plusOne -= adding ;
if(minusOne){
deducting = minusOne / 3 ;
minusOne %= 3 ;
}
if(plusOne) {
adding += (plusOne / 3) ;
plusOne %= 3 ;
}
plusOne += minusOne ;
plusOne /= 3 ;
deducting += plusOne ;
adding -= deducting ;
cout << adding << "\n" ;
}
int main()
{
__Heart__
int t ; cin >> t ; while(t--) solve() ;
}