#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    freopen("Diagonal.inp","r",stdin);
    freopen("Diagonal.out","w",stdout);
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        ll sum = 0;
        ll diag = 0;
        for (int j = 1; j <= n; j++) {
            ll x;
            cin >> x;
            if (x < 0) {
                cout << "NO";
                return 0;
            }
            sum += x;
            if (i == j) diag = x;
        }
        if (diag < sum - diag) {
            cout << "NO";
            return 0;
        }
        if (diag > sum - diag) cnt++;
    }
    if(cnt == 0){
        cout << "NO";
    }else{
        cout << "YES\n";
        cout << cnt;
    }
    return 0;
}
