n = int(input())
l = []
for i in range(n):
    l.extend(list(map(int, input().split())))
for i in range(n):
    for j in range(n):
        if i > j and l[i*n+j]:
            print('NO')
            break
    else:
        continue
    break
else:
    print('YES')