#include <bits/stdc++.h>
using namespace std;
int n, heads[2005], sizes, heads2[2005], sizes2, nn;
bool vis[2005];
struct edge {
  int v, next;
} eg[4000005], eg2[4000005];
void inits() {
  memset(heads, -1, sizeof(heads));
  memset(heads2, -1, sizeof(heads2));
  sizes = sizes2 = 0;
  return;
}
void add(int u, int v) {
  eg[sizes].v = v;
  eg[sizes].next = heads[u];
  heads[u] = sizes++;
  return;
}
void add2(int u, int v) {
  eg2[sizes2].v = v;
  eg2[sizes2].next = heads2[u];
  heads2[u] = sizes2++;
  return;
}
void dfs(int u) {
  vis[u] = 1, nn++;
  for (int i = heads[u]; i != -1; i = eg[i].next) {
    int v = eg[i].v;
    if (!vis[v]) dfs(v);
  }
}
void dfs2(int u) {
  vis[u] = 1, nn++;
  for (int i = heads2[u]; i != -1; i = eg2[i].next) {
    int v = eg2[i].v;
    if (!vis[v]) dfs2(v);
  }
}
int main() {
  int a;
  inits();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a);
      if (a) {
        add(i, j);
        add2(j, i);
      }
    }
  }
  nn = 0;
  memset(vis, 0, sizeof(vis));
  dfs(1);
  if (nn != n)
    printf("NO\n");
  else {
    nn = 0;
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    if (nn != n)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
