#include <bits/stdc++.h>
using namespace std;
bool E[2005][2005], rev[2005][2005], used[2005];
int N, cnt, src;
void dfs(int x, bool adj[2005][2005]) {
  if (used[x]) return;
  ++cnt;
  used[x] = true;
  for (int i = 1; i <= N; ++i)
    if (adj[x][i]) dfs(i, adj);
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j) {
      int a;
      scanf("%d", &a);
      E[i][j] = rev[j][i] = a > 0;
      if (i == j && a) src = i;
    }
  dfs(src, E);
  bool ans = cnt == N;
  cnt = 0;
  memset(used, 0, sizeof(used));
  dfs(src, rev);
  ans &= cnt == N;
  printf(ans ? "YES\n" : "NO\n");
}
