#include <bits/stdc++.h>
using namespace std;
char BUFFER[100000 + 5];
bool readn(int &n) { return scanf("%d", &n) == 1; }
bool readl(int &n) { return scanf("%I64d", &n) == 1; }
bool readd(double &n) { return scanf("%lf", &n) == 1; }
bool reads(string &s) {
  s = "";
  int n = scanf("%s", BUFFER);
  if (n == 1) s = BUFFER;
  return n == 1;
}
bool readln(string &s) {
  char *valid = gets(BUFFER);
  if (valid) s = BUFFER;
  return ((bool)valid);
}
const int maxn = 2005;
bool A[maxn][maxn];
bool vis[maxn];
int dfs(int u, int n) {
  if (vis[u]) return 0;
  vis[u] = true;
  int cnt = 1, v;
  for (v = 0; v < n; ++v)
    if (!vis[v] && A[u][v]) cnt += dfs(v, n);
  return cnt;
}
bool valid() {
  int i, j, n, m;
  cin >> n;
  for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j) {
      readn(m);
      A[i][j] = (m) ? 1 : 0;
    }
  memset((vis), (false), sizeof(vis));
  if (dfs(0, n) != n) return false;
  for (i = 0; i < n; ++i)
    for (j = 0; j < i; ++j) swap(A[i][j], A[j][i]);
  memset((vis), (false), sizeof(vis));
  if (dfs(0, n) != n) return false;
  return true;
}
int main() {
  if (valid())
    cout << "YES";
  else
    cout << "NO";
  printf("\n");
  return 0;
}
