#include <bits/stdc++.h>
using namespace std;
int G[2005][2005];
int R[2005][2005];
bool seen[2005];
int pre[2005], n, post[2005], cnt;
vector<int> ord;
void dfs(int u) {
  seen[u] = true;
  for (int v = 0; v < int(n); v++)
    if (G[u][v] > 0 && !seen[v]) dfs(v);
  ord.push_back(u);
}
void dfsr(int u) {
  cnt++;
  seen[u] = true;
  for (int v = 0; v < int(n); v++)
    if (R[u][v] > 0 && !seen[v]) dfsr(v);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(n); j++) cin >> G[i][j];
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(n); j++) R[i][j] = G[j][i];
  memset(seen, 0, sizeof(seen));
  ord.clear();
  for (int i = 0; i < int(n); i++)
    if (!seen[i]) dfs(i);
  reverse((ord).begin(), (ord).end());
  cnt = 0;
  memset(seen, 0, sizeof(seen));
  dfsr(ord[0]);
  if (cnt != n) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
