#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXN = 2005;
int head[MAXN];
int edge[MAXN * MAXN];
int next1[MAXN * MAXN];
int esz;
void addedge(int u, int v) {
  edge[esz] = v;
  next1[esz] = head[u];
  head[u] = esz++;
}
stack<int> s;
int pre[MAXN];
int low[MAXN];
int dfs_clock;
int sccno[MAXN];
int cnt;
void dfs(int u) {
  s.push(u);
  low[u] = pre[u] = ++dfs_clock;
  for (int i = head[u]; i + 1; i = next1[i]) {
    int v = edge[i];
    if (!pre[v]) {
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (!sccno[v])
      low[u] = min(low[u], low[v]);
  }
  if (low[u] != pre[u]) return;
  ++cnt;
  while (1) {
    int x = s.top();
    s.pop();
    sccno[x] = cnt;
    if (x == u) break;
  }
}
int main() {
  int n;
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      if (i == j) continue;
      if (x > 0) addedge(i, j);
    }
  for (int i = 1; i <= n; i++)
    if (!pre[i]) dfs(i);
  for (int i = 1; i < n; i++)
    if (sccno[i] == 0 || sccno[i + 1] == 0 || sccno[i] != sccno[i + 1]) {
      printf("NO\n");
      return 0;
    }
  printf("YES\n");
  return 0;
}
