#include <bits/stdc++.h>
using namespace std;
bool g[10000];
int n;
int a[2010][2010];
int b[10000];
bool check() {
  int t, w;
  t = 0;
  w = 1;
  b[1] = 1;
  for (int i = 0; i <= n; i++) g[i] = 0;
  g[1] = 1;
  while (t < w) {
    t++;
    for (int i = 1; i <= n; i++)
      if (!g[i] && a[b[t]][i]) {
        g[i] = 1;
        b[++w] = i;
      }
  }
  return (w == n);
}
int main() {
  int k;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j] > 0) a[i][j] = 1;
    }
  if (!check())
    printf("NO\n");
  else {
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++)
        k = a[i][j], a[i][j] = a[j][i], a[j][i] = k;
    if (check())
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
