#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(){
  

  int dataSets;

  while(true){
    vector<int> a;
    cin >> dataSets;
    for(int i=0;i<dataSets;i++){
      int tmpa;
      cin >> tmpa;
      a.push_back(tmpa);
      // cout << "a[" << i << "]: " << a[i] << endl;
    }

    int max=0;
    
    for(int i=0;i<dataSets;i++){
      // i+1?????£?¶?
      for(int j=0;j<dataSets-i;j++){
	int tmp=0;
	for(int k=0;k<i+1;k++){
	  tmp += a[j+k];
	  // cout << "(i,j,k): " << i << "," << j << "," << k << "  " << "a[" << j+k << "]   max:" << max << endl;
	}
	if(tmp>max){max=tmp;}
      }
    }
    
    cout << max << endl;
    
  }

  return 0;

}
  