/*
Coder: Shawn_Xue
Date: 2015.4.4
Result: AC
*/
#include <iostream>
#include <cstring>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 102;
int dp[maxn][maxn];
int a[maxn][maxn];
int main()
{
int n;
while(cin >> n)
{
// 以数组的形式保存三角结构
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= i; j ++) //特别注意,三角结构的形式
cin >> a[i][j];
// 初始化为0,否则会出错
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= i; j++)
{
// a[i][j] 只能来源于a[i-1][j]和a[i-1][j-1]
// 用dp保存每一次路线最大结果
dp[i][j] = max(dp[i-1][j],dp[i-1][j-1])+a[i][j];
}
int ans = dp[n][1];
for(int i = 2; i <= n; i ++)
{
ans = max(ans, dp[n][i]);
}
cout << ans << endl;
}
}