#定义节点和构造链表
#定义节点类
class Node:
def __init__(self, val):
self.val = val
self.next = None
#实例化节点
a = Node(1)
b = Node(2)
c = Node(3)
#构造链表
a.next = b
b.next = c
#print head
head = a
print(head)#print a, b, c
a = b
print(head)#print a, b, c ,(soft copy)
a = '123abbcc!@#'
str -> list: list(a)
str -> set: set(a)
b = ['1', '2', '3', 'a', 'b', 'c', '!', '@', '#']
list -> str: "".join(b)
list -> set: set(b)
c = set(['a', '!', 'c', 'b', '@', '#', '1', '3', '2'])
set->str: "".join(c)
set->list: list(c)
str.split(str="", num=string.count(str)).
if __name__ == '__main__':
T = int(input())
for _ in range(T):
n=int(input())
arr = [int(x) for x in input().split()]
print(maxSum(arr,n))