while 1:

	n=eval(input())

	if n==0:break

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

	#print r

	for i in range(1,n):

		r[i]=max(r[i-1]+r[i],r[i])

		#print r

	print(max(r))
while 1:

	n=eval(input())

	if n==0:break

	r=[int(input())for i in range(n)]

	for i in range(1,n):

		r[i]=max(r[i-1]+r[i],r[i])

	print(max(r))
while 1:
    n = eval(input())
    if n == 0:
        break
    r = [eval(input()) for i in range(n)]
    # print r
    for i in range(1, n):
        r[i] = max(r[i - 1] + r[i], r[i])
        # print r
    print(max(r))

while 1:
    n = eval(input())
    if n == 0:
        break
    r = [int(input()) for i in range(n)]
    for i in range(1, n):
        r[i] = max(r[i - 1] + r[i], r[i])
    print(max(r))

-    r = [eval(input()) for i in range(n)] -    # print r +    r = [int(input()) for i in range(n)] -        # print r