#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v, w;
} e[2000005];
int n, m, tot, fa[2005], dis[2005][2005], target[4005], pre[4005], last[2005],
    w[4005], mp[2005][2005];
bool used[2000005];
int find(int x) { return fa[x] == x ? fa[x] : fa[x] = find(fa[x]); }
bool cmp(edge a, edge b) { return a.w < b.w; }
void add(int u, int v, int ww) {
  target[++tot] = v;
  pre[tot] = last[u];
  last[u] = tot;
  w[tot] = ww;
}
void dfs(int u, int fa, int fir) {
  int ptr;
  for (ptr = last[u]; ptr; ptr = pre[ptr]) {
    if (target[ptr] != fa) {
      dis[fir][target[ptr]] = dis[fir][u] + w[ptr];
      dfs(target[ptr], u, fir);
    }
  }
}
int main() {
  int i, j, u, v, w;
  bool flg = 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", &w);
      if (w != 0) flg = 0;
      if (i < j) {
        e[++m].u = i;
        e[m].v = j;
        e[m].w = w;
        mp[i][j] = mp[j][i] = w;
      } else if (i == j) {
        if (w != 0) {
          puts("NO");
          return 0;
        }
      } else {
        if (mp[i][j] != w) {
          puts("NO");
          return 0;
        }
      }
    }
  }
  if (flg && n != 1) {
    puts("NO");
    return 0;
  }
  for (i = 1; i <= n; i++) fa[i] = i;
  sort(e + 1, e + m + 1, cmp);
  for (i = 1; i <= m; i++) {
    u = find(e[i].u);
    v = find(e[i].v);
    if (u != v) {
      add(e[i].u, e[i].v, e[i].w);
      add(e[i].v, e[i].u, e[i].w);
      fa[u] = v;
      used[i] = 1;
    }
  }
  for (i = 1; i <= n; i++) dfs(i, 0, i);
  for (i = 1; i <= m; i++) {
    if (!used[i]) {
      u = e[i].u;
      v = e[i].v;
      if (dis[u][v] != e[i].w) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
