#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include<bits/stdc++.h>
#define Q long long t;cin>>t;while(t--)

using namespace std;

typedef long long int ll;

void solve()
{
    ll n;

    cin>>n;

    ll r[n];

    ll m=n;

    for(ll i=0;i<n;i++)
    {
        cin>>r[i];
        if(r[i]==2)
            m--;
    }

    cout<<m<<endl;


}

int main()
{
    Q
    {
        solve();
    }
}
