import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main
(String[] args
) {
Scanner in
= new Scanner
(System.
in); int[][] s = new int[1001][1001];
while (in.hasNextInt())
{
int n = in.nextInt();
int ans = 0;
if(n==0)
{
break;
} else {
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
s[i][j] = in.nextInt();
s[i][j] += s[i - 1][j];
}
}
for (int j = 1; j <= n; j++)
{
for (int i = j; i <= n; i++)
{
s[i][j] += s[i - 1][j - 1];
}
for (int i = n - 1; i >= j; i--) {
s
[i
][j
] = Math.
max(s
[i
][j
], s
[i
+ 1][j
]); }
}
for (int i = 1; i <= n; i++) {
ans
= Math.
max(ans, s
[i
][i
]); }
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpwdWJsaWMgY2xhc3MgTWFpbgp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykKCXsKCQlTY2FubmVyIGluID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQlpbnRbXVtdIHMgPSBuZXcgaW50WzEwMDFdWzEwMDFdOwoJCXdoaWxlIChpbi5oYXNOZXh0SW50KCkpIAoJCXsKCQkJaW50IG4gPSBpbi5uZXh0SW50KCk7CgkJCWludCBhbnMgPSAwOwoJCQlpZihuPT0wKQoJCQl7CgkJCQlicmVhazsKCQkJfSBlbHNlIHsKCQkJCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgCgkJCQl7CgkJCQkJZm9yIChpbnQgaiA9IDE7IGogPD0gaTsgaisrKSAKCQkJCQl7CgkJCQkJCXNbaV1bal0gPSBpbi5uZXh0SW50KCk7CgkJCQkJCXNbaV1bal0gKz0gc1tpIC0gMV1bal07CgkJCQkJfQoJCQkJfQoJCQkJZm9yIChpbnQgaiA9IDE7IGogPD0gbjsgaisrKQoJCQkJewoJCQkJCWZvciAoaW50IGk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