#include <iostream>
#include <algorithm> 
using namespace std;

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int sum[n][n];
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < n; ++j){
				sum[i][j] = 0;
			}
		}

		for (int i = 0; i < n; ++i){
			cin >> sum[i][0];
		}

		int maximum = 0;
		for(int i = 0; i < n - 1; i++){
			for(int j = 1; j < n - i; j++){
				sum[i][j] = sum[i][j-1] + sum[i+j][0];
				maximum = max(maximum, sum[i][j]);
			}
		}

		cout << maximum << endl;
		cin >> n;
	}
	return 0;
}