#include <bits/stdc++.h>
using namespace std;
int low[2005];
int num[2005];
int a[2005][2005];
int n, cnt;
bool vis[2005];
void dfs(int u, int p) {
  vis[u] = true;
  low[u] = 1e9;
  num[u] = ++cnt;
  for (int v = 1; v <= n; v++)
    if (a[u][v]) {
      if (vis[v])
        low[u] = min(low[u], num[v]);
      else {
        dfs(v, u);
        low[u] = min(low[u], low[v]);
      }
    }
  if (num[u] < low[u]) {
    cout << "NO";
    exit(0);
  }
  if (num[u] == low[u] && u != 1) {
    cout << "NO";
    exit(0);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      a[i][j] = (a[i][j] > 0);
    }
  dfs(1, -1);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) return cout << "NO", 0;
  }
  cout << "YES";
  return 0;
}
