#include <iostream>
using namespace std;
int main() {
int n;
cin>>n;
int a[n][n];
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
cin>>a[i][j];
string ans="YES";
for(int i=0; i<n; i++){
if(a[i][i]!=0) ans="NO";
for(int j=0; j<n; j++)
if(a[i][j]!=a[j][i]) ans="NO";
}
cout<<ans;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIHsKCWludCBuOwoJY2luPj5uOwoJaW50IGFbbl1bbl07Cglmb3IoaW50IGk9MDsgaTxuOyBpKyspCgkJZm9yKGludCBqPTA7IGo8bjsgaisrKQoJCQljaW4+PmFbaV1bal07CglzdHJpbmcgYW5zPSJZRVMiOwoJZm9yKGludCBpPTA7IGk8bjsgaSsrKXsKCQlpZihhW2ldW2ldIT0wKSBhbnM9Ik5PIjsKCQlmb3IoaW50IGo9MDsgajxuOyBqKyspCgkJCWlmKGFbaV1bal0hPWFbal1baV0pIGFucz0iTk8iOwoJCX0KCWNvdXQ8PGFuczsKCQp9