#include <bits/stdc++.h>
#define forall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forr(i,a,b) for( int i=(a) ; i<=(b) ; ++i)
#define ford(i,a,b) for( int i=(a) ; i>=(b) ; --i)
#define sz(a) int((a).size())
#define cleanMyCode for( int ijk=1 ; ijk<2 ; ++ijk ) { int kkk=1;  }
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define f first
#define s second
#define task "Input"
using namespace std;
const long long MOD=1e9+7;

inline long long gcd(long long a, long long b) {long long r; while (b) {r = a % b; a = b; b = r;} return a;}
inline long long lcm(long long a, long long b) {return a / gcd(a, b) * b;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline long long sumDigit(long long x) { int ret = 0;string ss = to_string(x);for(auto &item: ss)ret += item - '0';return ret; }
#define ll long long
const long pp=2e5;

ll n,m,k,u,v,test,ans ;
ll a[pp],b[pp] ;

void read(){
    cin>>n;
    for(int i=1 ; i<=n ; ++i) cin>>a[i] ;
    ans=0;
    forr(i,1,n){
        if(a[i]!=2) ++ans;
    }
    cout<< ans << endl;
}

void work(){

}

int main()
{
//  freopen( task".inp" , "r" , stdin );
//  freopen( task".out" , "w" , stdout );
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();
    cin>>test;
    while(test--){
        read();
		work();
	}
    return 0;
}
