#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000;
char c[MAXN + 10][MAXN + 10];
bool bfs(int n) {
  vector<int> vis(n);
  queue<int> Q;
  Q.push(0);
  vis[0] = 1;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    for (int w = 0; w < (n); ++w) {
      if (!vis[w] && c[v][w]) {
        vis[w] = 1;
        Q.push(w);
      }
    }
  }
  for (int v = 0; v < (n); ++v) {
    if (!vis[v]) {
      return false;
    }
  }
  return true;
}
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) {
      int k;
      scanf("%d", &k);
      c[i][j] = k > 0 ? 1 : 0;
    }
  }
  if (!bfs(n)) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = i + 1; j < n; ++j) {
      swap(c[i][j], c[j][i]);
    }
  }
  puts(bfs(n) ? "YES" : "NO");
  return 0;
}
