n=eval(input())

while n:

    R=[eval(input()) for i in range(n)]

    x=R

    s=max(x)

    while n-1:

        R=R[1:]

        x=[a+b for a,b in zip(x[:-1],R)]

        s=max(s,max(x))

        n-=1

    print(s)

    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:
    R = [eval(input()) for i in range(n)]
    x = R
    s = max(x)
    while n - 1:
        R = R[1:]
        x = [a + b for a, b in zip(x[:-1], R)]
        s = max(s, max(x))
        n -= 1
    print(s)
    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())

-    R = [eval(input()) for i in range(n)] -    x = R -    s = max(x) -    while n - 1: -        R = R[1:] -        x = [a + b for a, b in zip(x[:-1], R)] -        s = max(s, max(x)) -        n -= 1 -    print(s) +    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))