#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000 + 10;
int n, a[MAXN][MAXN];
bool check(int first) {
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (a[first][i]) q.push(i);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (int i = 1; i <= n; ++i)
      if (a[t][i] && !a[first][i]) a[first][i] = true, q.push(i);
  }
  for (int i = 1; i <= n; ++i)
    if (!a[first][i]) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]), a[i][j] = (a[i][j] > 0);
  for (int i = 1; i <= n; ++i)
    if (a[i][i] == 1) {
      bool flag = check(i);
      if (flag) {
        for (int j = 1; j <= n; ++j)
          for (int k = j; k <= n; ++k) swap(a[j][k], a[k][j]);
        flag = check(i);
      }
      if (flag)
        puts("YES");
      else
        puts("NO");
      break;
    }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
