#include <bits/stdc++.h>
using namespace std;
int n, xb, w, tot, vet[4001], nxt[4001], head[2001], val[4001], fa[2001],
    dis[2001][2001], b[2001][2001];
bool f = 1, vis[2000001];
struct node {
  int u, v, w;
} a[2000001];
inline long long read() {
  long long sum = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
inline bool cmp(node x, node y) { return x.w < y.w; }
inline void add(int u, int v, int w) {
  vet[++tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
  val[tot] = w;
}
inline int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
inline void dfs(int u, int fa, int x) {
  for (register int i = head[u]; i; i = nxt[i])
    if (vet[i] != fa) {
      dis[x][vet[i]] = dis[x][u] + val[i];
      dfs(vet[i], u, x);
    }
}
signed main() {
  n = read();
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= n; ++j) {
      w = read();
      if (w != 0) f = 0;
      if (i < j) {
        a[++xb].u = i;
        a[xb].v = j;
        a[xb].w = w;
        b[i][j] = b[j][i] = w;
      } else if (i == j) {
        if (w != 0) {
          puts("NO");
          return 0;
        }
      } else {
        if (b[i][j] != w) {
          puts("NO");
          return 0;
        }
      }
    }
  if (f && n != 1) {
    puts("NO");
    return 0;
  }
  for (register int i = 1; i <= n; ++i) fa[i] = i;
  sort(a + 1, a + 1 + xb, cmp);
  for (register int i = 1; i <= xb; ++i) {
    int fu = find(a[i].u);
    int fv = find(a[i].v);
    if (fu != fv) {
      add(a[i].u, a[i].v, a[i].w);
      add(a[i].v, a[i].u, a[i].w);
      fa[fu] = fv;
      vis[i] = 1;
    }
  }
  for (register int i = 1; i <= n; ++i) dfs(i, 0, i);
  for (register int i = 1; i <= xb; ++i)
    if (!vis[i]) {
      int u = a[i].u, v = a[i].v;
      if (dis[u][v] != a[i].w) {
        puts("NO");
        return 0;
      }
    }
  puts("YES");
  return 0;
}
