Add = [[0, 1], [0, -1], [1, 0], [-1, 0]]

def dfs(map, y, x, cost)
  return [map] if cost.zero?
  result = Array.new
  Add.each do |(dy, dx)|
    ny = y + dy
    nx = x + dx
    next if ny < 0 || map.size <= ny
    next if nx < 0 || map.size <= nx
    next if map[ny][nx] <= 0
    next if cost < map[ny][nx]
    nm = map.dup.map(&:dup)
    nm[ny][nx] = 0
    nc = cost - map[ny][nx]
    result += dfs(nm, ny, nx, nc)
  end
  result
end

until (n = gets.to_i).zero?
  puzzle = Array.new
  n.times do puzzle.push(gets.split.map(&:to_i)) end

  queue = [puzzle.dup.map(&:dup)]
  (0...n).each do |i|
    (0...n).each do |j|
      next if puzzle[i][j] >= 0
      result = Array.new
      queue.each do |q|
        q[i][j] = 0
        result += dfs(q, i, j, -puzzle[i][j])
      end
      queue = result
    end
  end

  result = false
  queue.each do |q|
    ok = true
    q.each do |line|
      ok = false unless line.all?(&:zero?)
    end
    result = true if ok
  end
  puts result ? "YES" : "NO"
end