#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 3010;
int n;
int a[N][N];
int vis[N];
vector<int> ord;
void dfs(int u) {
  vis[u] = 1;
  for (int(i) = (0); (i) < (int)(n); (i)++) {
    if (a[u][i] != 0 && !vis[i]) dfs(i);
  }
  ord.push_back(u);
}
void rdfs(int u) {
  vis[u] = 1;
  for (int(i) = (0); (i) < (int)(n); (i)++)
    if (a[i][u] != 0 && !vis[i]) rdfs(i);
}
int main() {
  memset(vis, 0, sizeof vis);
  scanf("%d", &n);
  for (int(i) = (0); (i) < (int)(n); (i)++)
    for (int(j) = (0); (j) < (int)(n); (j)++) scanf("%d", &a[i][j]);
  dfs(0);
  int cnt1 = 0;
  for (int(i) = (0); (i) < (int)(n); (i)++)
    if (vis[i]) cnt1++;
  memset(vis, 0, sizeof vis);
  int cnt2 = 0;
  reverse((ord).begin(), (ord).end());
  rdfs(ord[0]);
  for (int(i) = (0); (i) < (int)(n); (i)++)
    if (vis[i]) cnt2++;
  if (cnt1 == cnt2 && cnt1 == n)
    printf("YES\n");
  else
    printf("NO\n");
}
