#include <iostream>
using namespace std;
int main() {
   int n;
   cin >> n;
   int temp;
   for(int i = 0;i<n;i++){
   for(int j = 0;j<n;j++){
     cin >> temp;
     if(i>j && temp!=0){
        cout << "NO" <<endl;
        return 0;
     }
   } 
   }
  cout << "YES" <<endl; 
}

不用数组也能做到