#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
vector<int> a[MAX];
vector<int> b[MAX];
vector<int> q;
bool mark[MAX];
void dfs1(int s) {
  mark[s] = true;
  for (int i = 0; i < a[s].size(); i++) {
    int now = a[s][i];
    if (!mark[now]) dfs1(now);
  }
  q.push_back(s);
}
void dfs2(int s) {
  mark[s] = true;
  for (int i = 0; i < b[s].size(); i++) {
    int now = b[s][i];
    if (!mark[now]) dfs2(now);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      if (x > 0) {
        a[i].push_back(j);
        b[j].push_back(i);
      }
    }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!mark[i]) dfs1(i);
  for (int i = 0; i < MAX; i++) mark[i] = false;
  for (int i = q.size() - 1; i >= 0; --i) {
    int now = q[i];
    if (mark[now] == false) {
      dfs2(now);
      ans++;
    }
  }
  if (ans == 1)
    printf("YES\n");
  else
    printf("NO\n");
}
