import java.util.*; import java.io.*; import java.math.*; class Main{ static void solve(){ int t = ni(); while(t-->0) { int n = ni(); int ans = 0; for(int i = 0 ; i < n ; i ++ ) { if(ni() == 1) ans++; } output.print(ans+" "); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - // static int ni(){ return Integer.parseInt(sc.next()); } static long nl(){ return Long.parseLong(sc.next()); } static double nd(){ return Double.parseDouble(sc.next()); } static String ns(){ return sc.next(); } static BigInteger bi(){ return sc.nextBigInteger(); } static BigDecimal bd(){ return sc.nextBigDecimal(); } static PrintWriter output; static Scanner sc ; public static void main(String[] args){ output = new PrintWriter(System.out); sc = new Scanner(System.in); solve(); output.flush(); } }