// Arup Guha
// 2/25/2020
// Solution to 2020 UCF HS Contest Problem: Lucky Charms

import java.util.*;

public class lucky {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int nC = stdin.nextInt();

		// Process all cases.
        for (int loop=0; loop<nC; loop++) {

            int n = stdin.nextInt();
            int res = 0;
			
			// Just see how many of the n numbers are equal to 4.
            for (int i=0; i<n; i++)
                if (stdin.nextInt() == 4)
                    res++;
				
			// Output result.
            System.out.println(res);
        }
    }
}