#include <bits/stdc++.h>
using namespace std;
int a[2050][2050], p[2050][2050], dis[2050], vis[2050];
int n;
priority_queue<pair<int, int> > q;
void spfa(int st) {
  for (int i = 1; i <= n; i++) dis[i] = -1, vis[i] = 0;
  dis[st] = 1;
  q.push(make_pair(-1, st));
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]++) continue;
    for (int v = 1; v <= n; v++) {
      if (a[u][v] == 0) continue;
      if (dis[v] == -1 || dis[v] > dis[u] + a[u][v])
        dis[v] = dis[u] + a[u][v], q.push(make_pair(-dis[v], v));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &p[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) a[i][j] = p[i][j];
  int flag = 0;
  spfa(1);
  for (int j = 1; j <= n; j++)
    if (dis[j] == -1) flag = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) a[i][j] = p[j][i];
  spfa(1);
  for (int j = 1; j <= n; j++)
    if (dis[j] == -1) flag = 1;
  if (flag)
    puts("NO");
  else
    puts("YES");
  return 0;
}
