#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int POWER[65];
int power(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    if (ret >= mod) ret %= mod;
    if (a >= mod) a %= mod;
    b >>= 1;
  }
  return ret;
}
int inv(int x) { return power(x, mod - 2); }
void precompute() {
  POWER[0] = 1;
  for (int i = 1; i < 63; i++) POWER[i] = POWER[i - 1] << 1LL;
}
const int maxn = 2e3 + 55;
int a[maxn][maxn];
vector<int> graph[maxn], graph2[maxn];
bool vis[maxn], vis2[maxn];
bool bfs(int curr, int n) {
  queue<int> q;
  for (int i = 0; i < ((int)graph[curr].size()); i++) {
    vis[graph[curr][i]] = 1;
    q.push(graph[curr][i]);
  }
  while (!q.empty()) {
    int val = q.front();
    q.pop();
    for (int i = 0; i < ((int)graph[val].size()); i++) {
      if (!vis[graph[val][i]]) {
        vis[graph[val][i]] = 1;
        q.push(graph[val][i]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) return 0;
  }
  return 1;
}
int main() {
  int n, root, pik = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j]) {
        graph[i].push_back(j);
        graph2[j].push_back(i);
        pik++;
      }
    }
    if (a[i][i]) {
      root = i;
    }
  }
  bool ch = bfs(root, n);
  if (!ch) {
    cout << "NO\n";
    return 0;
  }
  queue<int> q;
  for (int i = 0; i < ((int)graph2[root].size()); i++) {
    vis2[graph2[root][i]] = 1;
    q.push(graph2[root][i]);
  }
  while (!q.empty()) {
    int num = q.front();
    q.pop();
    for (int i = 0; i < ((int)graph2[num].size()); i++) {
      if (vis2[graph2[num][i]]) continue;
      vis2[graph2[num][i]] = 1;
      q.push(graph2[num][i]);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis2[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}
