#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
vector<int> g[2][N];
bool vis[N];
void dfs(int v, int ind) {
  vis[v] = true;
  for (int i = 0; i < g[ind][v].size(); i++)
    if (!vis[g[ind][v][i]]) dfs(g[ind][v][i], ind);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int x;
      scanf("%d", &x);
      if (i - j && x) {
        g[0][i].push_back(j);
        g[1][j].push_back(i);
      }
    }
  dfs(0, 0);
  if (!*min_element(vis, vis + n))
    printf("NO\n");
  else {
    fill(vis, vis + n, false);
    dfs(0, 1);
    if (!*min_element(vis, vis + n))
      printf("NO\n");
    else
      printf("YES\n");
  }
}
