#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 2 + 5;
const long long inf = 9223372036854775807;
int n, a[maxn][maxn], mark[maxn];
vector<int> adj[maxn], radj[maxn];
void sfd(int v) {
  mark[v] = 1;
  for (auto u : radj[v]) {
    if (mark[u] == 0) {
      sfd(u);
    }
  }
}
void dfs(int v) {
  mark[v] = 1;
  for (auto u : adj[v]) {
    if (mark[u] == 0) {
      dfs(u);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      if (a[i][j]) {
        adj[i].push_back(j);
        radj[j].push_back(i);
      }
    }
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (mark[i] == 0) {
      cout << "NO";
      return 0;
    }
  }
  memset(mark, 0, sizeof mark);
  sfd(1);
  for (int i = 1; i <= n; i++) {
    if (mark[i] == 0) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
