#include <iostream>

int main() {
  int t;
  std::cin >> t;
  while (t--) {
    int n; std::cin>>n;int arr[51] = {0};
    int count1 = 0, count2 = 0;
    for (int i = 0; i < n; i++) {
      std::cin >> arr[i];
      arr[i]==2 ? count2++ : count1++;
    }
    std::cout<<count1<<"\n";
  }
  return 0;
}