#include<iostream>
using namespace std;
int MaxSection(int *a, int n){
int max,i,sum;
max=-200000000;
sum=0;
for(i=0;i<n;i++){
sum=sum+a[i];
if(sum>max)
max=sum;
if(sum<0) sum=0;
}
return max;
}
void main(){
int a[]={2,2,3,0,5,1};
cout<<MaxSection(a,6)<<endl;
}
/*
{-1,2,3,-4,5}
{-1,-2,-3,-4,-5}
{-1,-2,-3,-4,-5,1}
{-1,2,0,-4,-5,1};
{2,-2,-3,-4,-5,1};
*/