import copy
n=int(input())
x=[]
for i in range(n):
a=list(map(int,input().split(' ')))
x.append(a)
xx=copy.deepcopy(x)
for j in range(n-1):
for i in range(1,n):
if i>j:
x[i][j]=0
if x==xx:
print('YES')
else:
print('NO')