#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void Read(T &x) {
  int f = 1;
  char t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -1;
    t = getchar();
  }
  x = 0;
  while (t >= '0' && t <= '9') {
    x = x * 10 + t - '0';
    t = getchar();
  }
  x *= f;
}
const int maxn = 2005;
const int maxm = 8000005;
int n;
int g[maxn][maxn];
int fst[maxn], v[maxm], nxt[maxm], e_cn;
int flag[maxn], dfn[maxn], low[maxn], dfn_clock, sz;
int q[maxn], r;
inline void addedge(int x, int y) {
  e_cn++, v[e_cn] = y;
  nxt[e_cn] = fst[x], fst[x] = e_cn;
}
void input() {
  memset(fst, 0, sizeof(fst));
  memset(low, 0, sizeof(low));
  memset(dfn, 0, sizeof(dfn));
  memset(flag, 0, sizeof(flag));
  e_cn = dfn_clock = sz = 0;
  Read(n);
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= n; j++) {
      Read(g[i][j]);
      g[i][j] = (g[i][j] > 0);
      if (g[i][j]) addedge(i, j);
    }
  }
}
void tarjan(int cn) {
  dfn[cn] = low[cn] = ++dfn_clock;
  flag[cn] = 2, q[++r] = cn;
  for (register int i = fst[cn]; i; i = nxt[i]) {
    if (!flag[v[i]]) {
      tarjan(v[i]);
      low[cn] = min(low[cn], low[v[i]]);
    } else if (flag[v[i]] == 2) {
      low[cn] = min(low[cn], dfn[v[i]]);
    }
  }
  if (dfn[cn] == low[cn]) {
    int cur;
    sz++;
    do {
      cur = q[r--];
      flag[cur] = 1;
    } while (cur != cn);
  }
}
void solve() {
  for (register int i = 1; i <= n; i++) {
    if (!flag[i]) {
      tarjan(i);
    }
  }
  if (sz == 1)
    printf("YES\n");
  else
    printf("NO\n");
}
int main() {
  input();
  solve();
  return 0;
}
