from collections import defaultdict, deque, Counter import copy from itertools import combinations, permutations, product, accumulate from heapq import heapify, heappop, heappush import math import bisect import sys # sys.setrecursionlimit(700000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 mod2 = 998244353 def ceil_div(x, y): return -(-x//y) ################################################# T = int(input()) for _ in range(T): N = int(input()) F = list(map(int, input().split())) ac = F.count(0) wa = ac+1 if ac+1 <= N else ac-1 print(wa)