#include <bits/stdc++.h>
using namespace std;
const int Mx = 2005;
int dis[Mx][Mx], n, dfn[Mx], low[Mx], col;
bool z;
void tarjan(int x, int f) {
  dfn[x] = dfn[f] + 1;
  low[x] = dfn[x];
  for (int i = 1; i <= n; i++) {
    if (dis[x][i] == 0) continue;
    if (dfn[i] == 0) {
      tarjan(i, x);
      low[x] = min(low[x], low[i]);
    } else {
      low[x] = min(low[x], dfn[i]);
    }
  }
  if (low[x] == dfn[x]) col++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &dis[i][j]);
      if (dis[i][j] > 0) z = 1;
    }
  }
  for (int i = 1; i <= n; i++)
    if (dfn[i] == 0) tarjan(i, 0);
  if (col == 1)
    puts("YES");
  else
    puts("NO");
}
