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

#define ll long long
#define db double
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define mpll map<ll, ll>
#define endl "\n"
int mod=1000000007;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		ll n,m, i, j;
		cin>>n;
		ll a[n+5];
		int upvote = 0;
		for(int i = 0; i < n; i++){
			cin>>a[i];
			if(a[i]!=2) upvote++;
		}
		cout<<upvote<<endl;
	}
	return 0;
}
