#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
int n;
bool chek[maxn];
vector<int> v[maxn], w[maxn], p;
void input() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int x;
      cin >> x;
      if (i != j && x > 0) {
        v[i].push_back(j);
        w[j].push_back(i);
      }
    }
}
void dffs(int x) {
  chek[x] = true;
  for (int i = 0; i < (int)w[x].size(); i++)
    if (!chek[w[x][i]]) dffs(w[x][i]);
}
void dfs(int x) {
  chek[x] = true;
  for (int i = 0; i < (int)v[x].size(); i++)
    if (!chek[v[x][i]]) dfs(v[x][i]);
  p.push_back(x);
}
void output() {
  for (int i = 0; i < n; i++)
    if (!chek[i]) dfs(i);
  for (int i = 0; i < n; i++) chek[i] = false;
  dffs(p[(int)p.size() - 1]);
  for (int i = 0; i < (int)p.size(); i++)
    if (!chek[p[i]]) {
      cout << "NO" << endl;
      return;
    }
  cout << "YES" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  input();
  output();
  return 0;
}
