#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 50000000;
const int maxn = 2010;
int n, A[maxn][maxn], vis[maxn];
int bfs(int src, int d) {
  queue<int> q;
  q.push(src);
  for (int i = 1; i <= n; i++) vis[i] = 0;
  vis[src] = 1;
  int ret = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 1; i <= n; i++) {
      if (!d && !vis[i] && A[u][i] > 0) {
        vis[i] = 1;
        ret += 1;
        q.push(i);
      }
      if (d && !vis[i] && A[i][u] > 0) {
        vis[i] = 1;
        ret += 1;
        q.push(i);
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &A[i][j]);
    }
  }
  if (bfs(1, 0) == n && bfs(1, 1) == n)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
