#include <bits/stdc++.h>
using namespace std;
const int MAXA = 1000000;
vector<bool> isPrime(MAXA + 1, true);
void sieve() {
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; 1LL * i * i <= MAXA; i++) {
        if (isPrime[i]) {
            for (int j = i * i; j <= MAXA; j += i) {
                isPrime[j] = false;
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    sieve();
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int x;
            cin >> x;
            if ((i == j || i + j == n - 1) && isPrime[x]) {
                ans++;
            }
        }
    }

    cout << ans;
    return 0;
}
