```
#include <stdio.h>
main()
{
int i,j,n,a[20],sum=0,msum =0;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(j=1;j<=n;j++)
{
sum+=a[j];
if(msum<sum)
msum=sum;
if(sum < 0)
sum = 0;
}
printf("\n%d",msum);
}
```

Recommended Topics