/*
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int main()
{

	int n,q,x[1024],s[1024]={};
	long long int t;
	int *a, *d;
	freopen("C:/JOI/2016-yo/2016-yo-t4/2016-yo-t4-in2.txt","r",stdin);
	freopen("C:/Users/TAKAKO YASUMATSU/Desktop/t4/b.txt","w",stdout);
	
	cin >> n >> t >> q;

	a = new int[n];
	d = new int[n];


	for(int i = 0; i < n; i++){

		cin >> a[i] >> d[i];

	}
	for(int i = 0; i < q; i++){

		cin >> x[i];

		s[i] = a[x[i]-1];

	}

	for(int i = 0; i < t; i++){
		for(int j = 0; j < n; j++){
			if( d[j] == 1 ){
				a[j]++;
			}
			else if( d[j] == 2 ){
				a[j]--;
			}
		}
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				if( a[j] == a[k] && j != k ){
					d[j] = 0;
				}
			}
		}
	}

	for(int i = 0; i < q; i++){
		
		cout << a[x[i]-1] << endl;
	}[
	return 0;
}
*/

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

	int A[100000]={0};
	int n,MAX = -100000;

		while(1){
			MAX = -100000;

			cin >> n;

			if( n == 0 ) break;

			for(int i = 0; i < n; i++){

				cin >> A[i];
	
			}

			for(int i = 1; i < n; i++){

				A[i] = max(A[i],A[i] + A[i-1]);
				MAX = max(A[i], MAX);

			}
	
			cout  << MAX << endl;

		}
	return 0;
}