#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
int n;
int a[N][N];
vector<int> g[N], rev_g[N];
void scan() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
      if (a[i][j]) {
        g[i].push_back(j);
        rev_g[j].push_back(i);
      }
    }
  }
}
bool used[N];
void dfs(int v) {
  used[v] = true;
  for (int u : g[v]) {
    if (!used[u]) {
      dfs(u);
    }
  }
}
bool used_rev[N];
void dfs_rev(int v) {
  used_rev[v] = true;
  for (int u : rev_g[v]) {
    if (!used_rev[u]) {
      dfs_rev(u);
    }
  }
}
bool check() {
  for (int v = 0; v < n; ++v) {
    if (a[v][v]) {
      dfs(v);
      dfs_rev(v);
      return count(used, used + n, false) == 0 &&
             count(used_rev, used_rev + n, false) == 0;
    }
  }
  assert(false);
  return false;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  scan();
  cout << (check() ? "YES\n" : "NO\n");
  return 0;
}
