import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[][] arr = new int[n+1][n+1];
int[][] dp = new int[n+1][n+1];
int ans = 0;
for(int i=1; i<=n; i++) {
String[] arr2 = br.readLine().split(" ");
for(int j=1; j<=i; j++) {
arr[i][j] = Integer.parseInt(arr2[j-1]);
}
}
dp[1][1] = arr[1][1];
for(int i=2; i<=n; i++) {
for(int j=1; j<=i; j++) {
dp[i][j] += Math.max(dp[i-1][j-1], dp[i-1][j])+arr[i][j];
}
}
for(int i=1; i<=n; i++) {
if(ans<dp[n][i]) { ans = dp[n][i]; }
}
System.out.println(ans);
}
}