#include <stdio.h>
#include <math.h>
int a[100010];
int main(){
int n;
scanf("%d",&n);
int Max = 0;
for(int i = 1; i <= n; i++){
scanf("%d",&a[i]);
//其实就两行
if(a[i-1] > 0) a[i] += a[i-1];
Max = fmax(Max,a[i]);
}
printf("%d",Max);
}