#include <bits/stdc++.h>
using namespace std;
const int maxn = 2001;
bool vis[maxn];
vector<pair<int, int> > g[maxn], rg[maxn];
int N;
void dfs(vector<pair<int, int> > g[], int cur, int pre) {
  vis[cur] = 1;
  for (vector<pair<int, int> >::iterator i = g[cur].begin(); i != g[cur].end();
       ++i) {
    if (!vis[i->second]) {
      dfs(g, i->second, cur);
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      int t;
      scanf("%d", &t);
      if (t != 0) {
        g[i].push_back(make_pair(i, j));
        rg[j].push_back(make_pair(j, i));
      }
    }
  }
  dfs(g, 1, 0);
  for (int i = 1; i <= N; ++i) {
    if (!vis[i]) {
      printf("NO\n");
      exit(0);
    }
  }
  memset(vis, 0, sizeof(vis));
  dfs(rg, 1, 0);
  for (int i = 1; i <= N; ++i) {
    if (!vis[i]) {
      printf("NO\n");
      exit(0);
    }
  }
  printf("YES\n");
  return 0;
}
