t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) s = sum(a) A = max(a) D = s - A print(D + min(A, D + 1))