#include <bits/stdc++.h>
using namespace std;
vector<int> G[2100], rG[2100];
int a[2100][2100];
bool bo[2100];
int n, tot, src;
queue<int> Q;
string solve() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j] > 0) {
        G[i].push_back(j);
        rG[j].push_back(i);
      }
    }
    if (a[i][i] > 0) src = i;
  }
  memset(bo, 0, sizeof(bo));
  tot = 0;
  Q.push(src);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    if (bo[x]) continue;
    bo[x] = 1;
    tot++;
    for (k = 0; k < G[x].size(); k++) {
      Q.push(G[x][k]);
    }
  }
  if (tot != n) return "NO";
  memset(bo, 0, sizeof(bo));
  tot = 0;
  Q.push(src);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    if (bo[x]) continue;
    bo[x] = 1;
    tot++;
    for (k = 0; k < rG[x].size(); k++) {
      Q.push(rG[x][k]);
    }
  }
  if (tot != n) return "NO";
  return "YES";
}
int main() {
  cout << solve() << endl;
  return 0;
}
