n = int(input()) for _ in range(n): k = list(map(int, input().split())) k = k[1:] t = sum(k) - len(k) + 1 print(t)