#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
	int n, k, p, m;
	while (cin >> n){
		if (0 == n) break;
		p = 0;
		m = INT_MIN;
		for(int i = 0; i < n; ++i){
			cin >> k;
			if ((0 != i) && (m < p + k)) m = p + k;
			p = k;
		}
		cout << m << "\n";
	}
	return 0;
}