#include <bits/stdc++.h>
const int N = 2000 + 10;
int n;
std::vector<int> adj[N];
int dfn[N], low[N], stack[N], top, timestamp;
bool instack[N];
int block_count, belong[N];
void dfs(int x) {
  timestamp++;
  dfn[x] = low[x] = timestamp;
  stack[++top] = x;
  instack[x] = true;
  for (int i = 0; i < ((int)(adj[x]).size()); i++) {
    int y = adj[x][i];
    if (!dfn[y]) {
      dfs(y);
      low[x] = std::min(low[x], low[y]);
    } else if (instack[y]) {
      low[x] = std::min(low[x], dfn[y]);
    }
  }
  if (low[x] == dfn[x]) {
    int y;
    block_count++;
    do {
      instack[y = stack[top--]] = false;
      belong[y] = block_count;
    } while (x != y);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int x;
      scanf("%d", &x);
      if (x > 0 && i != j) {
        adj[i].push_back(j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!dfn[i]) {
      dfs(i);
    }
  }
  for (int i = 1; i < n; i++) {
    if (belong[i] != belong[0]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
}
