#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FILL(a, b) memset(a, b, sizeof(a))
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector a(n, vector<int>(n));
int r = -1, c = -1;
FOR(i, 0, n)
FOR(j, 0, n)
{
cin >> a[i][j];
if (a[i][j] == -1)
{
r = i;
c = j;
}
}
cout << a[(r + 1) % n][c] + a[r][(c + 1) % n] - a[(r + 1) % n][(c + 1) % n] << "\n";
}