#include <bits/stdc++.h>
using namespace std;
int n, m, a[2001][2001], vis[2001], can[2001];
void solve(int u) {
  can[u] = 1;
  for (int i = 1; i <= n; i++)
    if (!can[i] && a[u][i]) solve(i);
}
void dfs(int u) {
  vis[u] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i] && a[i][u]) dfs(i);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  solve(1);
  dfs(1);
  for (int i = 1; i <= n; i++)
    if (!(can[i] && vis[i])) return puts("NO");
  puts("YES");
}
