#include <bits/stdc++.h> using namespace std; int main() { int n,a,ans=1<<31,now=0; cin>>n; while(n--) { cin>>a; now+=a; if(now>ans) ans=now; if(now<0) now=0; } cout<<ans; }