T = int(input()) for _ in range(T): N = int(input()) f = list(map(int, input().split())) cnt = 0 for v in f: if v==1: cnt += 1 print(cnt) print()