#include <bits/stdc++.h>
using namespace std;
int n, arr[2010][2010], arr2[2010][2010];
bool visited[2010];
void dfs(int v) {
  visited[v] = true;
  for (int i = 0; i < n; i++) {
    if (arr[v][i] != 0 && !visited[i]) dfs(i);
  }
}
void dfs2(int v) {
  visited[v] = true;
  for (int i = 0; i < n; i++) {
    if (arr2[v][i] != 0 && !visited[i]) dfs2(i);
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", arr[i] + j);
      arr[i][j] = (arr[i][j]) ? 1 : 0;
      arr2[j][i] = (arr[i][j]) ? 1 : 0;
    }
  }
  memset(visited, 0, sizeof(visited));
  dfs(0);
  for (int j = 0; j < n; j++) {
    if (!visited[j]) {
      printf("NO\n");
      return 0;
    }
  }
  memset(visited, 0, sizeof(visited));
  dfs2(0);
  for (int j = 0; j < n; j++) {
    if (!visited[j]) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
