n=eval(input())

while n:

    x=[]

    m=[]

    s=0

    for i in range(n):

        a=eval(input())

        x=[e+a for e in x]+[a]

        m.append(max(x))

    print(max(m))

    n=eval(input())
n=eval(input())

while n:

    x=-100000

    m=x

    s=0

    while n:

        a=eval(input())

        x=max(x,0)+a

        m=max(m,x)

        n-=1

    print(m)

    n=eval(input())
n = eval(input())
while n:
    x = []
    m = []
    s = 0
    for i in range(n):
        a = eval(input())
        x = [e + a for e in x] + [a]
        m.append(max(x))
    print(max(m))
    n = eval(input())

n = eval(input())
while n:
    x = -100000
    m = x
    s = 0
    while n:
        a = eval(input())
        x = max(x, 0) + a
        m = max(m, x)
        n -= 1
    print(m)
    n = eval(input())

-    x = [] -    m = [] +    x = -100000 +    m = x -    for i in range(n): +    while n: -        x = [e + a for e in x] + [a] -        m.append(max(x)) -    print(max(m)) +        x = max(x, 0) + a +        m = max(m, x) +        n -= 1 +    print(m)