import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { int n = sc.nextInt(); int count = 0; for (int j = 0; j < n; j++) { int f = sc.nextInt(); if (f == 1) { count++; } } System.out.println(count); } } }