输入样例:
6
-2 11 -4 13 -5 -2
输出样例:
20
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cctype>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#define mm(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
int main(){
int k;
cin>>k;
int sum1=0,result_sum=0;
while(k--)
{
int x;
cin>>x;
sum1+=x;
if(sum1<0)
sum1=0;
else if(result_sum<sum1)
result_sum=sum1;
}
cout<<result_sum;
}