#include <cstdio>
#include <algorithm>
using namespace std;
int a[111][111], f[111][111];
int main()
{
    int n;
    while (~scanf("%d", &n))
    {
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= i; j++)
                scanf("%d", &a[i][j]);
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= i; j++)
                f[i][j] = max(f[i - 1][j - 1], f[i - 1][j]) + a[i][j];
        printf("%d\n", *max_element(f[n], f[n] + n));
    }
    return 0;
}