#include<iostream>
#include<algorithm>

int main(){

	int n;
	while (std::cin >> n, n){

		int max = 0, before;
		std::cin >> before;

		for (int i = 1, a; i < n; i++){
			std::cin >> a;
			before = std::max(before + a, a);
			max = std::max(max, before);
		}

		std::cout << max << std::endl;
	}

	return 0;
}