#include <bits/stdc++.h>
using namespace std;
int n, c1, c2;
const int mxn = 2000 + 10;
int adj[mxn][mxn];
bool mark[mxn];
void dfs(int v) {
  mark[v] = true;
  c1++;
  for (int i = 0; i < n; i++) {
    if (adj[v][i] > 0 && !mark[i]) dfs(i);
  }
  return;
}
void dfs2(int v) {
  mark[v] = true;
  c2++;
  for (int i = 0; i < n; i++) {
    if (adj[i][v] > 0 && !mark[i]) dfs2(i);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cin >> adj[i][j];
  }
  dfs(0);
  for (int i = 0; i < n; i++) mark[i] = 0;
  dfs2(0);
  if (c1 == n && c2 == n)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
