#include<stdio.h> #include<string.h> #define N 110 int dp[N][N]; int a[N][N]; int Max(int v,int vv) { return v>vv?v:vv; } int main() { int n,i,j,k; while(scanf("%d",&n)!=EOF) { for(i=1;i<=n;i++) for(j=1;j<=i;j++) scanf("%d",&a[i][j]); memset(dp,0,sizeof(dp)); for(i=n;i>=1;i--) for(j=1;j<=i;j++) dp[i][j]=Max(dp[i+1][j],dp[i+1][j+1])+a[i][j]; printf("%d ",dp[1][1]); } return 0;}