#include <bits/stdc++.h>
using namespace std;
int n, d[2010], f[2010];
int adj[2010][2010], color[2010], rev[2010][2010], it;
vector<int> topo;
void input() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &adj[i][j]);
      rev[j][i] = adj[i][j];
    }
  }
}
void dfs(int source) {
  int i, j;
  it++;
  color[source] = 1;
  d[source] = it;
  for (i = 0; i < n; i++) {
    if (i != source && adj[source][i] > 0 && color[i] == 0) {
      dfs(i);
    }
  }
  it++;
  color[source] = 2;
  f[source] = it;
}
bool compare(int lhs, int rhs) { return f[lhs] > f[rhs]; }
void scc(int source) {
  int i, j;
  color[source] = 1;
  for (i = 0; i < n; i++) {
    if (i != source && color[i] == 0 && rev[source][i] > 0) {
      scc(i);
    }
  }
}
void solve() {
  int i, j;
  it = 0;
  memset(color, 0, sizeof(color));
  topo.clear();
  for (i = 0; i < n; i++) {
    topo.push_back(i);
    if (color[i] == 0) {
      dfs(i);
    }
  }
  sort(topo.begin(), topo.end(), compare);
  memset(color, 0, sizeof(color));
  scc(topo[0]);
  for (i = 0; i < n; i++) {
    if (color[i] == 0) {
      printf("NO\n");
      return;
    }
  }
  printf("YES\n");
}
int main() {
  input();
  solve();
  return 0;
}
