package algo.Baek;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main_1890_0826 {
static int N, Map[][], cnt;
static int delta[][] = {{0,1},{1,0}};
static long isCheck[][];
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = null;
N = Integer.parseInt(br.readLine());
cnt = 0;
Map = new int[N][N];
isCheck = new long[N][N];
for(int i = 0 ; i < N;i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j < N; j++) {
Map[i][j] = Integer.parseInt(st.nextToken());
}
}
isCheck[0][0] = 1;
for(int i = 0 ; i < N;i++) {
for (int j = 0; j < N; j++) {
if(isCheck[i][j] == 0 || Map[i][j] == 0) continue;
for (int k = 0; k < 2; k++) {
int nextX = i + delta[k][0]*Map[i][j];
int nextY = j + delta[k][1]*Map[i][j];
if(nextX >= N || nextY >= N) continue;
isCheck[nextX][nextY] += isCheck[i][j];
}
}
}
System.out.println(isCheck[N-1][N-1]);
}
}