#include <bits/stdc++.h>
#define N 1007
using namespace std;
inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
int a[N][N];
int main() {
int n = rd();
int r, c;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) {
a[i][j] = rd();
if (a[i][j] == -1) {r = i; c = j;}
}
int rr = (r < n ? r + 1 : r - 1);
int cc = (c < n ? c + 1 : c - 1);
printf("%d\n", a[rr][c] + a[r][cc] - a[rr][cc]);
return 0;
}