#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void fail() {
  cout << "NO\n";
  exit(0);
}
ll n, d[2010][2010], seen[2010];
vector<vector<pair<int, int>>> ady;
void dfs(int v, int p) {
  seen[n] = 1;
  for (auto pp : ady[v]) {
    int u = pp.first;
    if (u == p) continue;
    if (seen[u]) fail();
    dfs(u, v);
  }
}
int clog2(int n) {
  n--;
  int res = 0;
  while (n > 0) res++, n >>= 1;
  return res;
}
struct LCA {
  int n, root, logn;
  vector<int> lvl;
  vector<vector<ll>> up, dist;
  vector<vector<pair<int, int>>> ady;
  LCA(vector<vector<pair<int, int>>> ady, int root)
      : ady(ady), n(ady.size()), root(root), logn(clog2(n)) {
    init();
  }
  void init() {
    up.assign(n, vector<ll>(logn + 1));
    dist.assign(n, vector<ll>(logn + 1));
    lvl.assign(n, 0);
    dfs(root, root, 0, 0);
    for (int p = 1; p <= logn; p++) {
      for (int i = 0; i < n; i++) {
        up[i][p] = up[up[i][p - 1]][p - 1];
        dist[i][p] = dist[i][p - 1] + dist[up[i][p - 1]][p - 1];
      }
    }
  }
  void dfs(int v, int p, int l, int w) {
    lvl[v] = l;
    up[v][0] = p;
    dist[v][0] = w;
    for (auto pp : ady[v]) {
      int u = pp.first, ww = pp.second;
      if (u != p) dfs(u, v, l + 1, ww);
    }
  }
  int jump(int u, int d) {
    for (int p = logn; p >= 0; p--) {
      if (d & (1 << p)) u = up[u][p];
    }
    return u;
  }
  int lca(int u, int v) {
    if (lvl[u] > lvl[v]) swap(u, v);
    v = jump(v, lvl[v] - lvl[u]);
    if (u == v) return u;
    for (int p = logn; p >= 0; p--) {
      if (up[u][p] != up[v][p]) {
        u = up[u][p], v = up[v][p];
      }
    }
    return up[u][0];
  }
  ll path(int u, int v) {
    int low = lca(u, v);
    int ju = lvl[u] - lvl[low], jv = lvl[v] - lvl[low];
    ll res = 0;
    for (int p = logn; p >= 0; p--) {
      if (ju & (1 << p)) {
        res += dist[u][p];
        u = up[u][p];
      }
      if (jv & (1 << p)) {
        res += dist[v][p];
        v = up[v][p];
      }
    }
    return res;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> d[i][j];
  ll p[2010] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        if (d[i][j] != 0) fail();
      } else {
        if (d[i][j] == 0 || d[i][j] != d[j][i]) fail();
      }
      if (i != j && d[0][i] == d[0][j] + d[j][i] && d[0][j] > d[0][p[i]]) {
        p[i] = j;
      }
    }
  }
  ady.assign(n, vector<pair<int, int>>());
  for (int i = 1; i < n; i++) ady[p[i]].push_back({i, d[p[i]][i]});
  dfs(0, 0);
  auto lca = LCA(ady, 0);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (d[i][j] != lca.path(i, j)) fail();
    }
  }
  cout << "YES\n";
}
