Ntc = int(input())

for i in range(Ntc):
    _ = input()
    tc = list(map(int, input().split(' ')))
    tc.sort()
    ans = 0
    # for half of element
    for j in range(len(tc) // 2):
        # if -ve and +ve, alternating
        if tc[j] < 0 and tc[-(j+1)] > 0:
            # add sum
            ans += tc[j] + tc[-(j+1)]
        else:
            break
    print(ans)
