#include <bits/stdc++.h>
using namespace std;
const int maxN = 2000 + 10;
int n;
vector<int> adj[maxN][2];
bool mark[maxN][2];
void dfs(int v, int ind) {
  mark[v][ind] = true;
  for (int i = 0; i < adj[v][ind].size(); i++)
    if (!mark[adj[v][ind][i]][ind]) dfs(adj[v][ind][i], ind);
}
int st = -1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int w;
      scanf("%d", &w);
      if (!w) continue;
      if (i == j)
        if (w > 0) st = i;
      adj[i][0].push_back(j);
      adj[j][1].push_back(i);
    }
  }
  if (st == -1) return cout << "NO" << '\n', 0;
  dfs(st, 0);
  dfs(st, 1);
  for (int i = 0; i < n; i++)
    if (!(mark[i][0] && mark[i][1])) return cout << "NO" << '\n', 0;
  cout << "YES" << '\n';
  return 0;
}
