#include <bits/stdc++.h>
using namespace std;
int n, x, tot, cnt, num, top, low[10010], vis[10010], dfn[10010], head[10010],
    a[10010];
struct Node {
  int x, y, nxt;
} side[4001010];
inline void add(int x, int y) {
  tot++;
  side[tot].x = x;
  side[tot].y = y;
  side[tot].nxt = head[x];
  head[x] = tot;
}
inline void Tarjan(int x) {
  dfn[x] = low[x] = ++cnt;
  a[++top] = x;
  vis[x] = 1;
  for (register int i = head[x]; i; i = side[i].nxt) {
    int y = side[i].y;
    if (!dfn[y]) {
      Tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (vis[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    num++;
    if (num > 1) return;
    while (x != a[top + 1]) {
      vis[a[top]] = 0;
      top--;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= n; j++) {
      scanf("%d", &x);
      if (x > 0) add(i, j);
    }
  for (register int i = 1; i <= n; i++) {
    if (num > 1) {
      puts("NO");
      return 0;
    }
    if (!dfn[i]) Tarjan(i);
  }
  if (num == 1)
    puts("YES");
  else
    puts("NO");
}
