#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define SZ(S) ((int) ((S).size()))
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
int n, a[1011][1011], sum[1011][1011], f[1011][1011];
int main() {
ios :: sync_with_stdio(false); cin.tie(NULL);
cout << (fixed) << setprecision(6);
while (cin >> n && n) {
FOR(i,1,n) FOR(j,1,i) {
cin >> a[i][j];
}
FOR(j,1,n) FOR(i,j,n) {
int ii = i - j + 1;
sum[j][ii] = sum[j][ii-1] + a[i][j];
}
memset(f, 0, sizeof f);
FOR(j,1,n) {
int ln = n - j + 1;
FORD(k,ln,0) {
f[j][k] = f[j-1][k] + sum[j][k];
if (k < ln) f[j][k] = max(f[j][k], f[j][k+1]);
}
// PR0(f[j], ln+1);
}
cout << f[n][0] << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIEZPUihpLGEsYikgZm9yKGludCBpPShhKSxfYj0oYik7IGk8PV9iOyBpKyspCiNkZWZpbmUgRk9SRChpLGEsYikgZm9yKGludCBpPShhKSxfYj0oYik7IGk+PV9iOyBpLS0pCiNkZWZpbmUgUkVQKGksYSkgZm9yKGludCBpPTAsX2E9KGEpOyBpPF9hOyBpKyspCiNkZWZpbmUgRUFDSChpdCxhKSBmb3IoX190eXBlb2YoYS5iZWdpbigpKSBpdCA9IGEuYmVnaW4oKTsgaXQgIT0gYS5lbmQoKTsgKytpdCkKI2RlZmluZSBTWihTKSAoKGludCkgKChTKS5zaXplKCkpKQoKI2RlZmluZSBERUJVRyh4KSB7IGNvdXQgPDwgI3ggPDwgIiA9ICIgPDwgeCA8PCBlbmRsOyB9CiNkZWZpbmUgUFIoYSxuKSB7IGNvdXQgPDwgI2EgPDwgIiA9ICI7IEZPUihfLDEsbikgY291dCA8PCBhW19dIDw8ICcgJzsgY291dCA8PCBlbmRsOyB9CiNkZWZpbmUgUFIwKGEsbikgeyBjb3V0IDw8ICNhIDw8ICIgPSAiOyBSRVAoXyxuKSBjb3V0IDw8IGFbX10gPDwgJyAnOyBjb3V0IDw8IGVuZGw7IH0KCmludCBuLCBhWzEwMTFdWzEwMTFdLCBzdW1bMTAxMV1bMTAxMV0sIGZbMTAxMV1bMTAxMV07CgppbnQgbWFpbigpIHsKICAgIGlvcyA6OiBzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyBjaW4udGllKE5VTEwpOwogICAgY291dCA8PCAoZml4ZWQpIDw8IHNldHByZWNpc2lvbig2KTsKICAgIHdoaWxlIChjaW4gPj4gbiAmJiBuKSB7CiAgICAgICAgRk9SKGksMSxuKSBGT1IoaiwxLGkpIHsKICAgICAgICAgICAgY2luID4+IGFbaV1bal07CiAgICAgICAgfQogICAgICAgIEZPUihqLDEsbikgRk9SKGksaixuKSB7CiAgICAgICAgICAgIGludCBpaSA9IGkgLSBqICsgMTsKICAgICAgICAgICAgc3VtW2pdW2lpXSA9IHN1bVtqXVtpaS0xXSArIGFbaV1bal07CiAgICAgICAgfQogICAgICAgIG1lbXNldChmLCAwLCBzaXplb2YgZik7CiAgICAgICAgRk9SKGosMSxuKSB7CiAgICAgICAgICAgIGludCBsbiA9IG4gLSBqICsgMTsKICAgICAgICAgICAgRk9SRChrLGxuLDApIHsKICAgICAgICAgICAgICAgIGZbal1ba10gPSBmW2otMV1ba10gKyBzdW1bal1ba107CiAgICAgICAgICAgICAgICBpZiAoayA8IGxuKSBmW2pdW2tdID0gbWF4KGZbal1ba10sIGZbal1baysxXSk7CiAgICAgICAgICAgIH0KLy8gICAgICAgICAgICBQUjAoZltqXSwgbG4rMSk7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgZltuXVswXSA8PCBlbmRsOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCg==