T = int(input()) for _ in range(T): n = int(input()) f = list(map(int,input().split())) if sum(f) == n: print(0) else: print(sum(f))