#include<stdio.h>
int max(int a, int b)
{
return (a > b ? a : b);
}
int main()
{
int n;
while (scanf("%d",&n) != EOF)
{
int data[100][100] = {0};
int i, j;
for (i = 0; i < n; i++)
for (j = 0; j <= i; j++)
scanf("%d",&data[i][j]);
int dp[100][100] = {0};
for (j = 0; j < n; j++)
dp[n-1][j] = data[n-1][j];
for (i = n - 1; i >= 0; i--)
{
for (j = 0; j < n; j++)
{
dp[i][j] = data[i][j] + max(dp[i+1][j], dp[i+1][j+1]);
}
}
printf("%d\n",dp[0][0]);
}
return 0;
}