from collections import Counter T = int(input()) for _ in range(T): N = int(input()) cnt = Counter(list(map(int, input().split()))) print(cnt[1])