#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int maxn = 2003;
int n;
int a[maxn][maxn];
void read() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
}
vector<int> rev_adj[maxn], adj[maxn];
vector<int> order;
bool used[maxn];
void dfs1(int ver) {
  used[ver] = true;
  for (auto i : adj[ver])
    if (!used[i]) dfs1(i);
  order.push_back(ver);
}
void dfs2(int ver) {
  used[ver] = true;
  for (auto i : rev_adj[ver])
    if (!used[i]) dfs2(i);
}
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[i][j] > 0) {
        adj[i].push_back(j);
        rev_adj[j].push_back(i);
      }
  for (int i = 1; i <= n; i++)
    if (!used[i]) dfs1(i);
  memset(used, false, sizeof(used));
  reverse(order.begin(), order.end());
  int cnt = 0;
  for (auto i : order)
    if (!used[i]) {
      dfs2(i);
      cnt++;
    }
  if (cnt == 1)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  solve();
}
