https://pintia.cn/problem-sets/15/problems/709
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n,x;
long long s=0,t=0;
scanf("%d",&n);
while(n--){
scanf("%d",&x);
t+=x;
if(t>s)
s=t;
if(t<0)
t=0;
}
printf("%lld\n",s);
return 0;
}