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

#define ll 				long long
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define f(i,a,n)        for(ll i=a;i<n;i++)
#define ve              vector
#define ss              second 
#define ff              first
#define pf              pop_front
#define pob             pop_back
#define psf             push_front
#define res(x)          cout<<x<<'\n'
#define read(t)         ll t;cin>>t
#define ppi             pair<pair<int>>
#define pii             pair<ll,ll>
#define vii             vector<ll,ll>
#define INFI            1000000000000000000;
#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
const int mod =1000000007;


void solve(){
   int n;
   cin>>n;
   int a[n];
   f(i,0,n) cin>>a[i];
   int cnt=0;
   f(i,0,n){
       if(a[i]!=2) cnt++;
   }
   cout<<cnt<<endl;

}
int32_t main()
{
	fast;
    int t=1;
    cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

