#include <bits/stdc++.h>
using namespace std;
const int MAX = 2010;
stack<int> mystack;
vector<int> G[MAX];
int pre[MAX], lowlink[MAX], sccno[MAX], dfs_clock, scc_cnt;
void dfs(int u) {
  pre[u] = lowlink[u] = ++dfs_clock;
  mystack.push(u);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!pre[v]) {
      dfs(v);
      lowlink[u] = min(lowlink[u], lowlink[v]);
    } else if (!sccno[v])
      lowlink[u] = min(lowlink[u], pre[v]);
  }
  if (lowlink[u] == pre[u]) {
    scc_cnt++;
    while (true) {
      int x = mystack.top();
      mystack.pop();
      sccno[x] = scc_cnt;
      if (x == u) break;
    }
  }
}
void find_scc(int n) {
  dfs_clock = scc_cnt = 0;
  memset(sccno, 0, sizeof(sccno));
  memset(pre, 0, sizeof(pre));
  for (int i = 0; i < n; i++)
    if (!pre[i]) dfs(i);
}
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &x);
      if (x > 0) G[i].push_back(j);
    }
  }
  find_scc(n);
  if (scc_cnt == 1)
    puts("YES");
  else
    puts("NO");
  return 0;
}
