#!/usr/bin/ruby
#
# 1034.rb: Line Puzzle
#

require 'set'

### constant

DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]

### subroutines

def fl_rec(x, y, sum, set0)
  if sum == 0
    return [set0.clone]
  end

  sets = Set.new

  for dxy in DXYS
    x0 = x + dxy[0]
    y0 = y + dxy[1]
    id0 = y0 * $n + x0

    if x0 >= 0 && x0 < $n && y0 >= 0 && y0 < $n && 
        ! $used0[id0] && $mtx[id0] <= sum
      $used0[id0] = true
      sets += fl_rec(x0, y0, sum - $mtx[id0], set0 + [id0] )
      $used0[id0] = false
    end
  end

  sets
end

def find_lines(org)
  sum = -$mtx[org]
  x = org % $n
  y = org / $n
  $used0 = $used.clone

  fl_rec(x, y, sum, Set.new)
end

def check_osets(osets, k)
  if k >= osets.length
    return true
  end

  for set0 in osets[k]
    set0.each{|id| $used[id] = true}
    return true if check_osets(osets, k + 1)
    set0.each{|id| $used[id] = false}
  end

  false
end

### main

loop do
  $n = gets.to_i
  break if $n == 0

  $mtx = []
  origins = []
  sum = 0

  for y in (0...$n)
    nums = gets.split.map(&:to_i)
    sum += nums.inject(:+)

    for x in (0...$n)
      origins << (y * $n + x) if nums[x] < 0
    end

    $mtx += nums
  end
  #p $mtx
  #p origins
  #p sum

  if sum != 0
    puts 'NO'
    next
  end

  $used = ($n * $n).times.map{false}
  origins.each{|i| $used[i] = true}
  #p $used

  ok = true
  osets = []

  for org in origins
    oset = find_lines(org)
    if oset.empty?
      ok = false
      break
    end
    osets << oset
  end
  #p osets

  if ! ok
    puts 'NO'
    next
  end

  changed = true

  while changed
    changed = false
    posets, osets = osets, []

    for poset in posets
      oset = Set.new

      for set0 in poset
        if set0.select{|id| $used[id]}.empty?
          oset << set0
        else
          changed = true
        end
      end

      if oset.empty?
        ok = false
        break
      end

      if oset.length == 1
        oset.first.each{|id| $used[id] = true}
        changed = true
        next
      end

      osets << oset
    end

    break if ! ok
  end

  if ! ok
    puts 'NO'
    next
  end

  if osets.empty?
    puts 'YES'
    next
  end
  #osets.each{|oset| p oset}
  #p $used

  ok = check_osets(osets, 0)
  puts (ok ? 'YES' : 'NO')
end