#include <bits/stdc++.h>

using namespace std;

ifstream fi ("DCONMAX.INP");
ofstream fo ("DCONMAX.OUT");

int main(){
  int n;
  fi>>n;
  int a[n],i;
  for (i=0;i<n;i++){fi>>a[i];}
  int tong, ans=a[0],k;
  for (i=0;i<n;i++){tong = a[i] ;
    for (k=i+1;k<n;k++){
        tong=tong+a[k];
        if (tong>ans){ans=tong;}
    }
  }
  fo<<ans;
}
