#include<iostream> using namespace std; int main() { int i,n,ans,dp[100],a[100]; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; dp[1]=a[1]; ans=a[1]; for(i=2;i<=n;++i){ if(a[i]<=dp[i-1]+a[i]) dp[i]=dp[i-1]+a[i]; else dp[i]=a[i]; if(ans<dp[i]) ans=dp[i]; } cout<<ans; return 0; }