#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
vector<int> g1[N], g2[N];
bool vis1[N], vis2[N];
int n;
void dfs1(int v) {
  vis1[v] = true;
  for (auto u : g1[v])
    if (!vis1[u]) dfs1(u);
}
void dfs2(int v) {
  vis2[v] = true;
  for (auto u : g2[v])
    if (!vis2[u]) dfs2(u);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int a;
      scanf("%d", &a);
      if (!a or i == j) continue;
      g1[i].push_back(j);
      g2[j].push_back(i);
    }
  dfs1(0);
  dfs2(0);
  for (int i = 0; i < n; i++) {
    if (!vis1[i] or !vis2[i]) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
}
