#include <bits/stdc++.h>
int N;
int Nr[2222][2222];
int Check1[2222];
int Check2[2222];
int Cnt1 = 0;
int Cnt2 = 0;
void DFS1(int v) {
  Cnt1++;
  Check1[v] = 1;
  for (int i = 1; i <= N; i++) {
    if (i == v) continue;
    if (Check1[i] == 1) continue;
    if (Nr[v][i] > 0) DFS1(i);
  }
}
void DFS2(int v) {
  Cnt2++;
  Check2[v] = 1;
  for (int i = 1; i <= N; i++) {
    if (i == v) continue;
    if (Check2[i] == 1) continue;
    if (Nr[i][v] > 0) DFS2(i);
  }
}
int main() {
  scanf("%d", &N);
  int v = 0;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      scanf("%d", &Nr[i][j]);
      if (i == j && Nr[i][j] > 0) v = i;
    }
  DFS1(v);
  DFS2(v);
  if (Cnt1 == N && Cnt2 == N)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
