import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Solution {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int N = Integer.parseInt(br.readLine());
int[][] t = new int[N][N];
int[][] d = new int[N][N];
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j <= i; j++) {
t[i][j] = Integer.parseInt(st.nextToken());
}
}
d[0][0] = t[0][0];
for (int i = 1; i < N; i++) {
for (int j = 0; j < N; j++) {
if (j == 0) {
d[i][j] = d[i - 1][j] + t[i][j];
} else {
d[i][j] = Math.max(d[i - 1][j], d[i - 1][j - 1]) + t[i][j];
}
}
}
int max = 0;
for (int i = 0; i < N; i++) {
max = max > d[N - 1][i] ? max : d[N - 1][i];
}
System.out.print(max);
}
}