//Задача
//1-ая личная интернет-олимпиада сезона 2009-2010
//Автор решения: Ганеев Рустам, ganeev@rain.ifmo.ru
//Неверное решение - нестрогое преобладание матрицы
import java.io.*;
import java.util.*;
import java.math.*;

public class diagonal_rg_wa implements Runnable {

	public static void main(String[] args) {
		new Thread(new diagonal_rg_wa()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failure: " + message);
		}
	}

	String FNAME = "diagonal";

	private void solve() throws IOException {
		int n = nextInt();
		myAssert(n > 0 && n < 10001, "Wrong N value");
		int cnt = 0;
		boolean diag = true;
		int a[][] = new int[n + 1][n + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = nextInt();
				myAssert(Math.abs(a[i][j]) < 1001, "");
				a[i][n] += a[i][j];
			}
			a[i][n] -= 2 * a[i][i];
			diag = a[i][n] <= 0;
			cnt += a[i][n] < 0 ? 1 : 0;
		}
		if (diag) {
			out.println("YES");
			out.print(cnt);
		} else {
			out.print("NO");
		}
	}
}
