#include <bits/stdc++.h>
using namespace std;
int N, mat[2010][2010], ti[2010], tot, Ans;
bool vis[2010];
void Dfs(int now) {
  vis[now] = 1;
  for (int i = 1; i <= N; ++i)
    if (mat[now][i] && !vis[i]) Dfs(i);
  ti[++tot] = now;
}
void Dfs1(int now) {
  vis[now] = 1;
  ++Ans;
  for (int i = 1; i <= N; ++i)
    if (mat[i][now] && !vis[i]) Dfs1(i);
}
void Scc() {
  for (int i = 1; i <= N; ++i)
    if (!vis[i]) Dfs(i);
  memset(vis, 0, sizeof(vis));
  Dfs1(ti[N]);
}
int main() {
  int i, j, k;
  scanf("%d", &N);
  for (i = 1; i <= N; ++i)
    for (j = 1; j <= N; ++j) scanf("%d", &mat[i][j]);
  Scc();
  if (Ans == N)
    puts("YES");
  else
    puts("NO");
  return 0;
}
