#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="NO";
for(int i=0; i<n; i++){
if(a[i][i]!=0) ans="YES";
}
cout<<ans;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIHsKCWludCBuOwoJY2luPj5uOwoJaW50IGFbbl1bbl07Cglmb3IoaW50IGk9MDsgaTxuOyBpKyspCgkJZm9yKGludCBqPTA7IGo8bjsgaisrKQoJCQljaW4+PmFbaV1bal07CglzdHJpbmcgYW5zPSJOTyI7Cglmb3IoaW50IGk9MDsgaTxuOyBpKyspewoJCWlmKGFbaV1baV0hPTApIGFucz0iWUVTIjsKCQl9Cgljb3V0PDxhbnM7CgkKfQ==