#include <bits/stdc++.h>
using namespace std;
int n, M[2002][2002];
bool V[2002];
vector<int> L, L_;
void dfs(int inicial, vector<int> &Li) {
  Li.push_back(inicial);
  V[inicial] = 1;
  for (int i = 0; i < n; ++i)
    if (!V[i] && M[inicial][i]) dfs(i, Li);
}
bool Conexo() {
  dfs(0, L);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= i; ++j) swap(M[i][j], M[j][i]);
  memset(V, 0, sizeof V);
  dfs(0, L_);
  return L.size() == n && L_.size() == n;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &M[i][j]);
  if (Conexo())
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
