#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int a;
		int b = 0;
		int max = -1000000;
		for(int i=0;i<n;i++){
			cin >> a;
			b += a;
			if(max<b) max = b;
		}
		cout << max << endl;
	}
}