#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, ne;
} t[4000010];
int head[2010], cnt;
int dfn[2010], low[2010], scc, sta[4010], top, col[2010];
bool in_sta[2010];
int n;
inline void add(const int &x, const int &y) {
  t[++cnt].to = y;
  t[cnt].ne = head[x];
  head[x] = cnt;
}
inline void tarjan_dfs(const int &x) {
  dfn[x] = low[x] = ++cnt;
  sta[++top] = x;
  in_sta[x] = true;
  for (int i = head[x]; i; i = t[i].ne) {
    int y = t[i].to;
    if (!dfn[y]) {
      tarjan_dfs(y);
      low[x] = min(low[x], low[y]);
    } else if (in_sta[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    scc++;
    int y = 23433;
    while (y != x) {
      y = sta[top--];
      col[y] = scc;
      in_sta[y] = false;
    }
  }
}
int main() {
  int _;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &_);
      if (_ >= 1) add(i, j);
    }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan_dfs(i);
  if (scc <= 1)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
