#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int inf = 1e18;
vector<long long int> bfs(
    long long int src,
    vector<vector<pair<long long int, long long int>>> &Graph) {
  long long int n = Graph.size();
  vector<long long int> dis(n, inf);
  dis[src] = 0;
  queue<long long int> q;
  q.push(src);
  while (!q.empty()) {
    long long int temp = q.front();
    q.pop();
    for (auto &x : Graph[temp]) {
      long long int to = x.first;
      long long int w = x.second;
      if (dis[to] > dis[temp] + w) {
        dis[to] = dis[temp] + w;
        q.push(to);
      }
    }
  }
  return dis;
}
mt19937 gen;
vector<long long int> par;
long long int find(long long int a) {
  if (par[a] == a) return a;
  return par[a] = find(par[a]);
}
void unite(long long int a, long long int b) {
  if (gen() % 2) swap(a, b);
  par[a] = b;
}
void solve() {
  long long int n;
  cin >> n;
  par.resize(n + 1);
  iota(par.begin(), par.end(), 0);
  vector<vector<long long int>> mat(n + 1, vector<long long int>(n + 1));
  vector<pair<long long int, pair<long long int, long long int>>> edges;
  vector<vector<pair<long long int, long long int>>> Graph(n + 1);
  for (long long int i = (long long int)1; i <= (long long int)n; i++) {
    for (long long int j = (long long int)1; j <= (long long int)n; j++) {
      cin >> mat[i][j];
    }
  }
  for (long long int i = (long long int)1; i <= (long long int)n; i++) {
    for (long long int j = (long long int)1; j <= (long long int)n; j++) {
      edges.push_back({mat[i][j], {i, j}});
    }
  }
  sort(edges.begin(), edges.end());
  for (auto &x : edges) {
    long long int u = x.second.first;
    long long int v = x.second.second;
    long long int w = x.first;
    long long int nu = find(u), nv = find(v);
    if (nu == nv) continue;
    Graph[u].push_back({v, w});
    Graph[v].push_back({u, w});
    unite(nu, nv);
  }
  for (long long int i = (long long int)1; i <= (long long int)n; i++) {
    vector<long long int> dis = bfs(i, Graph);
    for (long long int j = (long long int)1; j <= (long long int)n; j++) {
      if ((dis[j] != mat[i][j]) || (mat[i][j] == 0 && i != j)) {
        cout << "NO" << '\n';
        return;
      }
    }
  }
  cout << "YES" << '\n';
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
