for t in range(int(input())): x = input() if x == '2': print(t+1) else: print(sum(map(int, input().split()))-1)