#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 1005;

int n, a[MAXN][MAXN];
int dp[MAXN][MAXN], ma[MAXN][MAXN], sum[MAXN][MAXN];

int main() {
	while (1==scanf("%d",&n) && n) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= i; ++j) {
				scanf("%d", &a[i][j]);
			}
		}
		int ans = 0;
		for (int j = 1; j <= n; ++j) {
			for (int i = j; i <= n; ++i) {
				sum[i][j] = sum[i-1][j] + a[i][j];
				dp[i][j] = ma[i-1][j-1] + sum[i][j];
				ans = max(ans, dp[i][j]);
			}
			ma[n][j] = dp[n][j];
			for (int i = n-1; i >=j; --i) {
				ma[i][j] = max(ma[i+1][j], dp[i][j]);
			}
		}
		printf("%d\n", ans);
	}
}
