def solution():
# Use a breakpoint in the code line below to debug your script.
T = int(input())
for j in range(T):
N = int(input())
arr = list(map(int, input().split()))
dp = [-1 for _ in range(N)]
for i in range(N):
if (i == 0): dp[i] = arr[0]
else : dp[i] = max(dp[i-1] + arr[i], arr[i])
print("#%d %d" % (j+1, max(dp)))
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
solution()