#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v, w;
} edge[2007 * 2007];
int a[2007][2007], fa[2007], dis[2007][2007];
vector<pair<int, int> > G[2007];
int cmp(Edge ka, Edge kb) { return ka.w < kb.w; }
int findset(int x) {
  if (x != fa[x]) fa[x] = findset(fa[x]);
  return fa[x];
}
void dfs(int u, int fa, int ori) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first;
    if (v == fa) continue;
    dis[ori][v] = dis[ori][u] + G[u][i].second;
    dfs(v, u, ori);
  }
}
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) scanf("%I64d", &a[i][j]);
  int tag = 1;
  for (i = 1; i <= n; i++) {
    fa[i] = i;
    for (j = 1; j <= n; j++) {
      if ((i == j && a[i][j] != 0) || (i != j && a[i][j] == 0) ||
          (a[i][j] != a[j][i])) {
        tag = 0;
        break;
      }
    }
    if (!tag) break;
  }
  if (!tag) {
    puts("NO");
  } else {
    int tot = 0;
    for (i = 1; i <= n; i++)
      for (j = i + 1; j <= n; j++)
        edge[tot].u = i, edge[tot].v = j, edge[tot++].w = a[i][j];
    sort(edge, edge + tot, cmp);
    for (i = 0; i < tot; i++) {
      int u = edge[i].u, v = edge[i].v, w = edge[i].w;
      int fx = findset(u), fy = findset(v);
      if (fx != fy) {
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
        fa[fx] = fy;
      }
    }
    for (i = 1; i <= n; i++) {
      dis[i][i] = 0;
      dfs(i, 0, i);
      for (j = 1; j <= n; j++) {
        if (a[i][j] != dis[i][j]) {
          tag = 0;
          break;
        }
      }
      if (!tag) break;
    }
    if (!tag)
      puts("NO");
    else
      puts("YES");
  }
}
