#include <bits/stdc++.h>
const long long MOD = 1000000007;
const double EPS = 1e-9;
using namespace std;
const int N = 2048;
int n, x;
vector<int> G[N];
vector<int> rG[N];
vector<int> vs;
bool used[N];
int cmp[N];
void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    if (!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}
void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for (int i = 0; i < rG[v].size(); i++) {
    if (!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = int(0); i <= int((n)-1); i++)
    for (int j = int(0); j <= int((n)-1); j++) {
      scanf("%d", &x);
      if (x != 0) {
        G[i].push_back(j);
        rG[j].push_back(i);
      }
    }
  for (int v = 0; v < n; v++) {
    if (!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]]) rdfs(vs[i], k++);
  }
  puts(k == 1 ? "YES" : "NO");
  return 0;
}
