#include<cstdio>
int main() {
int a, dp, maxT, left, right, leftmp, n;
while (scanf("%d", &n) != EOF) {
maxT = dp = left = right = 0; //初始化很重要!!!
bool flag = true; //标记是否全为负数
if (n == 0) break;
for (int i = 0; i < n; i++) {
scanf("%d", &a);
if (dp >...