// Задача ""
// 1-ая личная интернет-олимпиада сезона 2009-2010
// Автор задачи: Владимир Ульянцев, ulyantsev@rain.ifmo.ru
// Автор решения: Роман Колганов, Roman.Kolganov@gmail.com
import java.util.*;
import java.io.*;

public class diagonal_rk implements Runnable {
	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

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

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			String filename = "diagonal_rk".substring(0, "diagonal_rk"
					.indexOf('_'));
			in = new BufferedReader(new FileReader(filename + ".in"));
			st = new StringTokenizer("");
			out = new PrintWriter(new File(filename + ".out"));
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (Exception e) {
				throw new Error("Unexpected end of file");
			}
		}
		return st.nextToken();
	}

	private long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}
	
	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	void solve() throws IOException {
		int n = nextInt();
		long[] matrixLine = new long[n];
		int eq = 0;
		int greater = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				matrixLine[j] = nextLong();
			}
			long sum = 0;
			for (int j = 0; j < n && sum <= matrixLine[i]; ++j) {
				if (j != i) {
					sum += matrixLine[j];
				}
			}
			if (sum < matrixLine[i]) {
				++greater;
			}
			if (sum == matrixLine[i]) {
				++eq;
			}
		}
		if (greater + eq == n && greater > 0) {
			out.println("YES");
			out.println(greater);
		} else {
			out.println("NO");
		}
	}

}