#include <bits/stdc++.h>
using namespace std;
const int MAX = 2 * 1000 + 10;
const int MAXLOG = 17;
int a[MAX][MAX];
int par[MAX][MAXLOG];
vector<int> v[MAX], vr[MAX];
bool mark[2][MAX];
int cnt_1, cnt_2, cnt;
void DFS(int x) {
  mark[0][x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int p = v[x][i];
    if (!mark[0][p]) {
      cnt_1++;
      DFS(p);
    }
  }
}
void DFS_2(int x) {
  mark[1][x] = 1;
  for (int i = 0; i < vr[x].size(); i++) {
    int p = vr[x][i];
    if (!mark[1][p]) {
      cnt_2++;
      DFS_2(p);
    }
  }
}
int main() {
  int n, s;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &s);
      if (i == j) continue;
      if (s > 0) {
        a[i][j] = 1;
        v[i].push_back(j);
        vr[j].push_back(i);
      }
    }
  }
  DFS(1);
  DFS_2(1);
  if (cnt_1 == n - 1 && cnt_2 == n - 1)
    printf("YES\n");
  else
    printf("NO\n");
}
