students-score-1
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

PIET'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


N=eval(input())
a=list(map(int,input().split()))
sum=0
r=0
for i in range(N):
	sum=sum+a[i]
	if sum<0:
		sum=0
	if sum>r:
		r=sum
print(r)




def find_consistency():
	count=int(input())
	if count==0:
		print("0")
		return 0
	score=input().split()
	score_sum={}
	score_sum_b={}
	total_sum=0
	i=0
	for sc in score:
		s=int(sc)
		total_sum=total_sum+s
		score_sum[i]=total_sum
		i +=1
	total_count=i
	i=0
	j=0
	max_val=score_sum[0]
	while i<total_count:
		j=i+1
		while j<total_count:
			if (score_sum[j]-score_sum[i])>max_val:
					max_val=score_sum[j]-score_sum[i]
			j +=1
		i +=1
	print(max_val)




if __name__=="__main__":
	find_consistency()