# def max(a, b): # if a>b: # return a # else: # return b def seqmax(s): dp=[0]*1000000 A = [0] k=1 for i in range(len(s)): A.insert(k,s[i]) k+=1 #print(A) #dp.append(0) m = -2**63 for i in range(1, len(A)): dp[i] = max(A[i], A[i]+dp[i-1]) if m<dp[i]: m=dp[i] print(m) while True: try: n = input() if n == '': continue n=int(n) s = list(map(int, input().split())) seqmax(s) except: break