n=int(input()) list1=[] for i in range(n): a=list(map(int,input().split())) list1.append(a) num=0 for j in range(1,n): for k in range(j): if list1[j][k]==0: num+=1 else: break if num==n*(n-1)//2: print("YES") else: print("NO")