#define REP(i,n) for (int i=0;i<(n);i++)
#include <iostream>
using namespace std;

int main(){
        int N;
        while(cin >> N && N > 0){
                int a[N];
                REP(i,N){
                        cin >> a[i];
                }

                int maximum = 0;
                REP(i,N){
                        int maximum_i = 0;
                        REP(j,N-i){
                                int sum = 0;
                                REP(k,i+1){
                                        sum += a[j+k];
                                }
                        maximum_i = max(sum,maximum_i);
                        }
                maximum = max(maximum_i,maximum);
                }
                cout << maximum << endl;

        }
}