import java.util.*;
public class Main {
static final int N = 110;
static int[][] f = new int[N][N];
static int n;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = Integer.parseInt(sc.nextLine());
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
f[i][j] = sc.nextInt();
int ans = dp();
System.out.println(ans);
}
static int dp() {
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (i == 1) f[i][j] += f[i][j - 1];
else if (j == 1) f[i][j] += f[i - 1][j];
else f[i][j] += Math.min(f[i - 1][j], f[i][j - 1]);
return f[n][n];
}
}