import numpy as np

maxMap = np.

n = int(input())
triangle = []
for _ in range(n):
    nums = input().split()
    tmp = []
    for num in nums:
        tmp.append(int(num))
    triangle.append(tmp)

def maxSum(i, j):
    if i == n:
        return triangle[i-1][j-1]

    x = maxSum(i+1, j)
    y = maxSum(i+1, j+1)
    return max(x, y) + triangle[i-1][j-1]

print(triangle)
print(maxSum(1, 1))

45ccc51f34cc7b4fad9b16478455dc05324961fd
import numpy as np

maxMap = np.

n = int(input())
triangle = []
for _ in range(n):
    nums = input().split()
    tmp = []
    for num in nums:
        tmp.append(int(num))
    triangle.append(tmp)

def maxSum(i, j):
    if i == n:
        return triangle[i-1][j-1]

    x = maxSum(i+1, j)
    y = maxSum(i+1, j+1)
    return max(x, y) + triangle[i-1][j-1]

print(triangle)
print(maxSum(1, 1))
