'''
简单二维动态规划
'''
from functools import lru_cache
@lru_cache(typed=False, maxsize=128000000)
def dp(i, j):
if i == 0 and j == 0:
return grid[0][0]
ans = 0x7fffffff
if i - 1 >= 0:
ans = min(ans, dp(i - 1, j) + grid[i][j])
if j - 1 >= 0:
ans = min(ans, dp(i, j - 1) + grid[i][j])
return ans
N = int(input())
grid = []
for i in range(N):
grid.append(list(map(int, input().split())))
print(dp(N - 1, N - 1))