Subodh's CS department has been continuously organizing mock placement drives for students. If a student under-performs negative point is rewarded otherwise positive points is rewarded. The HOD wants to find consistency of a student. So, he wants to find out maximum consistent sum of a student score only if his/her overall rating is positive.
Help HOD in doing so. 

Input

The first line contain number of drives N over which the analysis is to be done. The second line contains score of student in those N drives.

Output

Print a single integer i.e. the maximum consistent score of the student if it is positive otherwise output 0 (zero).

SAMPLE INPUT
8
-1 -4  4 -2 0 1 4 -5

SAMPLE OUTPUT
7
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'

def mssl(l):
    best = cur = 0
    for i in l:
        cur = max(cur + i, 0)
        best = max(best, cur)
    return best
    

n = int(raw_input())
a = []
while len(a) != n:
	a += map(int, raw_input().split())
	
print  mssl(a)