Recall that the sequence $b$ is a a subsequence of the sequence $a$ if $b$ can be derived from $a$ by removing zero or more elements without changing the order of the remaining elements. For example, if $a=[1, 2, 1, 3, 1, 2, 1]$, then possible subsequences are: $[1, 1, 1, 1]$, $[3]$ and $[1, 2, 1, 3, 1, 2, 1]$, but not $[3, 2, 3]$ and $[1, 1, 1, 1, 2]$.

You are given a sequence $a$ consisting of $n$ positive and negative elements (there is no zeros in the sequence).

Your task is to choose maximum by size (length) alternating subsequence of the given sequence (i.e. the sign of each next element is the opposite from the sign of the current element, like positive-negative-positive and so on or negative-positive-negative and so on). Among all such subsequences, you have to choose one which has the maximum sum of elements.

In other words, if the maximum length of alternating subsequence is $k$ then your task is to find the maximum sum of elements of some alternating subsequence of length $k$.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Then $t$ test cases follow.

The first line of the test case contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of elements in $a$. The second line of the test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^9 \le a_i \le 10^9, a_i \ne 0$), where $a_i$ is the $i$-th element of $a$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$).


-----Output-----

For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $a$.


-----Example-----
Input
4
5
1 2 3 -1 -2
4
-1 -2 -1 -3
10
-2 8 3 8 -4 -15 5 -2 -3 1
6
1 -1000000000 1 -1000000000 1 -1000000000

Output
2
-1
6
-2999999997



-----Note-----

In the first test case of the example, one of the possible answers is $[1, 2, \underline{3}, \underline{-1}, -2]$.

In the second test case of the example, one of the possible answers is $[-1, -2, \underline{-1}, -3]$.

In the third test case of the example, one of the possible answers is $[\underline{-2}, 8, 3, \underline{8}, \underline{-4}, -15, \underline{5}, \underline{-2}, -3, \underline{1}]$.

In the fourth test case of the example, one of the possible answers is $[\underline{1}, \underline{-1000000000}, \underline{1}, \underline{-1000000000}, \underline{1}, \underline{-1000000000}]$.

Difficulty: introductory

Starter code:

Solutions:
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    a=[]
    lis=[]
    prevsign=-1
    if l[0]>0:
        prevsign=1
    else:
        prevsign=0
    i=0
    for i in l:
        if (i>0 and prevsign==1) or (i<0 and prevsign==0):
            lis.append(i)
        else:
            if prevsign==1:
                a.append(max(lis))
                lis=[]
                lis.append(i)
                prevsign=0
            else:
                a.append(max(lis))
                lis=[]
                lis.append(i)
                prevsign=1
    
    if prevsign==1:
        a.append(max(lis))
        lis=[]
        lis.append(i)
        prevsign=0
    else:
        a.append(max(lis))
        lis=[]
        lis.append(i)
        prevsign=1
    print(sum(a))
        


t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    b = [a[0]]
    ans = 0
    for i in range(1,n):
        if b[0] < 0 and a[i] < 0:
            b.append(a[i])
        if b[0] > 0 and a[i] > 0:
            b.append(a[i])
        if b[0] < 0 and a[i] > 0:
            ans += max(b)
            b = [a[i]]
        if b[0] > 0 and a[i] < 0:
            ans += max(b)
            b = [a[i]]
    if len(b) >= 1:
        ans += max(b)
    print(ans)

# a = list(map(int,input().split()))
# n,m = map(int,input().split())




from math import *
test = int(input())
for test_case in range(test):
	n = int(input())
	a = list(map(int,input().split()))
	if(a[0] > 0):
		f = 1
	else:
		f = 0
	i = 0
	ans = 0
	while(i < n):
		m = a[i]
		if(f == 1):
			while(i < n and a[i] > 0):
				m = max(m,a[i])
				i += 1
		else:
			while(i < n and a[i] < 0):
				m = max(m,a[i])
				i += 1
		f = f^1
		#print(m)
		ans += m
	print(ans)


for i in range(int(input())):
	n=int(input())
	a=[int(j) for j in input().split()]
	s=0
	mx=a[0]
	for j in range(n):
		if(a[j]*mx<0):
			s+=mx
			mx=a[j]
		else:
			mx=max(mx, a[j])
	print(s+mx)

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))

    i = 1
    b, tmp = [], [a[0]]
    while i < n:
        if a[i] * tmp[0] > 0:
            tmp.append(a[i])
        else:
            b.append(tmp)
            tmp = [a[i]]
        i += 1

    b.append(tmp)

    s = 0
    for bb in b:
        s += max(bb)

    print(s)


import sys
lines = sys.stdin.readlines()
T = int(lines[0].strip())
for t in range(T):
    n = int(lines[2*t+1].strip())
    nums = list(map(int,  lines[2*t+2].strip().split(" ")))
    res = []
    tmp = nums[0]
    for i in range(1, len(nums)):
        if nums[i] * nums[i-1] > 0:
            tmp = max(tmp, nums[i])
        else:
            res.append(tmp)
            tmp = nums[i]
    res.append(tmp)
    print(sum(res))


from sys import stdin
input = stdin.readline
t = int(input())
for rew in range(t):
	n = int(input())
	l = list(map(int,input().split()))
	wyn = 0
	listka = []
	cur = [l[0]]
	for i in range(1,n):
		if cur and l[i] * cur[-1] < 0:
			listka.append(cur)
			cur = [l[i]]
		else:
			cur.append(l[i])
	listka.append(cur)
	for i in listka:
		wyn += max(i)
	print(wyn)

t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = a[0]
	l = a[0]
	for i in range(1, n):
		if a[i] > 0 and l < 0 or a[i] < 0 and l > 0:
			l = a[i]
			s += l
		elif l < a[i]:
			s += a[i] - l
			l = a[i]
	print(s)

from sys import stdin, exit
from bisect import *
from heapq import heappush, heappop
from itertools import combinations
from collections import deque
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

for _ in range(int(input())):
    n = int(input())
    arr = lmi()
    i = 0
    tmp = []
    ans = 0
    while i < n:
        tmp.append(arr[i])
        i+= 1
        if i >=n or (arr[i] > 0) != (arr[i-1] > 0):
            ans += max(tmp)
            tmp = []
    print(ans)

t=int(input())
for pp in range(0,t):
    n=int(input())
    ip=list(map(int,input().split()))
    if(ip[0]>0):
        arr=[]
        curr=ip[0]
        sign=1
        for i in range(1,len(ip)):
            num=ip[i]
            if(num>0 and sign==1 and num>curr):
                curr=num
            elif(num<0 and sign==1):
                arr.append(curr)
                curr=num
                sign=-1
            elif(sign==-1):
                if(num<0 and num>curr):
                    curr=num
                if(num>0):
                    arr.append(curr)
                    curr=num
                    sign=1
        arr.append(curr)
    else:
        arr=[]
        curr=ip[0]
        sign=-1
        for i in range(1,len(ip)):
            num=ip[i]
            if(num>0 and sign==1 and num>curr):
                curr=num
            elif(num<0 and sign==1):
                arr.append(curr)
                curr=num
                sign=-1
            elif(sign==-1):
                if(num<0 and num>curr):
                    curr=num
                if(num>0):
                    arr.append(curr)
                    curr=num
                    sign=1
        arr.append(curr)
    ss=sum(arr)
    print(ss)

t = int(input())
for i in range(t):
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = 0
    index = 0
    now = a[0]
    mx = a[0]
    while index < n:
        while index < n and now * a[index] > 0:
            mx = max(mx, a[index])
            index += 1
        ans += mx
        if index == n:
            break
        now = a[index]
        mx = a[index]
    print(ans)


t = int(input())

for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().strip().split()]
    i = 0
    res = 0
    while i<n:
        if a[i]>0:
            pi = 0 
            while i<n and a[i]>0:
                pi = max(pi, a[i])
                i+=1
                
            res+=pi
        else:
            ni = -10**10
            while i<n and a[i]<0:
                ni = max(ni,a[i])
                i+=1
            res+=ni
    print(res)

t = int(input())
for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    ind = 0
    ans = 0
    while ind < n:
        cur = -10000000001
        if a[ind] < 0:
            while ind < n and a[ind] < 0:
                cur = max(a[ind], cur)
                ind += 1
        else:
            while ind < n and a[ind] > 0:
                cur = max(a[ind], cur)
                ind += 1
        ans += cur
    print(ans)

t=int(input())
for i in range(t):
    n=int(input())
    nums=list(map(int,input().split()))
    currentmax=nums[0]
    ans=0
    if nums[0]>0:
        pos=1
    else:
        pos=-1
    for j in range(1,n):
        if nums[j]>0:
            if pos==1:
                if nums[j]>currentmax:
                    currentmax=nums[j]
            else:
                ans=ans+currentmax
                currentmax=nums[j]
                pos=1
        else:
            if pos==-1:
                if nums[j]>currentmax:
                    currentmax=nums[j]
            else:
                ans=ans+currentmax
                currentmax=nums[j]
                pos=-1
    ans=ans+currentmax
    print(ans)