#include<bits/stdc++.h>
using namespace std;

#define ll                long long
#define ld                long double
#define vec               vector
#define vi                vector<ll>
#define si                set<ll>
#define pii               pair<ll,ll>
#define mii               map<ll,ll>
#define vip               vector<pair<ll,ll>> 
#define pii               pair<ll,ll>
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define ff                first
#define ss                second
#define mp                make_pair
#define mt                make_tuple
#define endl              "\n"
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define r(i,n)              rep(i,0,n)
#define rev(i,a,b)        for(ll i=a;i>b;i--)
#define co                cout<<
#define ci                cin>>
#define el                co endl
#define te(i)             ll i; cin>>i
#define fo(i,a,b,p)       for (int i=a; i<b; i+=p)
#define foi(n)            fo(i,0,n,1)
#define foj(n)            fo(j,0,n,1)
#define set(a,b)          memset(a,b,sizeof(a))
#define let(x,a)          __typeof(a) x(a)
#define tr(v,it)          for( let(it,v.begin()); it != v.end() ; it++)
#define trav(a,b)         for(auto a:b)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ps(x,y)           fixed<<setprecision(y)<<x
#define setbits(x)        __builtin_popcount(x)
#define zrobits(x)        __builtin_ctzll(x)
#define show(v)           rep(i,0,sz(v))cout<<v[i]<<" ";cout<<endl
#define showarr(v)        rep(i,0,*(&v + 1) - v)cout<<v[i]<<" ";cout<<endl
#define showvip(v)        rep(i,0,sz(v))cout<<v[i].ss<<" "<<v[i].ff<<"\n";cout<<"\n" 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
typedef priority_queue <int> pqi;
typedef priority_queue <int, vector<int>, greater<int> > mpqi;
typedef set<int>::iterator sit;    
typedef vector<int>::iterator vit;
typedef vec<long double> vd;
typedef vec<string> vs;
typedef multiset <int> msi;
typedef pair<int, int> parii;
typedef pair<int, string> paris;
typedef vector<parii> vpii;
typedef vector<paris> vpis;

const long long INF=1e9+7;
const int32_t M=1e9+7;
const int32_t MM=998244353;
const int N=5e5+5;
const int32_t maxn=N;

void solve(ll w){
    ll n,b[4]={0};ci n;ll a[n];
    r(i,n){ci a[i];b[a[i]]++;}
    // ll x=b[1];
    // if(b[3]<b[2])x+=b[3];
    // else {x+=b[2];b[3]-=b[2];x+=(b[3]+1)/2;}
    co b[1]+b[3];el;

   
    
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

     ll ttt=1;
    cin>>ttt;
    rep(w,0,ttt)  solve(w);
    // cerr<<duration.count()/1000.0<<" ms\n";
    return 0;
} 