#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
int main() {
  long long n, i, ans;
  cin >> n;
  int p[n * n];
  for (i = 1; i <= n * n; i++) cin >> p[i];
  if (n == 3)
    cout << "1";
  else if (n == 1 || n == 2)
    cout << "0";
  else
    cout << (((n - 2) * (n - 2)) - ((n - 4) * (n - 4))) - 1;
  return 0;
}
