#include <bits/stdc++.h>
using namespace std;
int part, tot, dfs_time;
int ins[2010], sk[2010], dfn[2010], low[2010];
vector<int> graph[2010];
void tarjan(int t) {
  dfn[t] = low[t] = dfs_time++;
  sk[tot++] = t;
  ins[t] = 1;
  for (int i = 0; i < graph[t].size(); i++) {
    int k = graph[t][i];
    if (dfn[k] == -1) {
      tarjan(k);
      low[t] = min(low[t], low[k]);
    } else if (ins[k])
      low[t] = min(low[t], dfn[k]);
  }
  if (dfn[t] == low[t]) {
    part++;
    int k;
    do {
      k = sk[--tot];
      ins[k] = 0;
    } while (k != t);
  }
}
int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &x);
      if (i != j && x > 0) graph[i].push_back(j);
    }
  tot = part = dfs_time = 0;
  memset(dfn, -1, sizeof(dfn));
  tarjan(0);
  if (part > 1) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++)
    if (dfn[i] == -1) {
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
  return 0;
}
