#include <bits/stdc++.h>
using namespace std;
int head[2005], fa[2005], top, zhan[2005];
long long n, cnt, tot, a[2005][2005], dist[2005][2005];
bool vis[2005];
struct bian {
  int x, y, z;
} b[2000010];
bool operator<(const bian &a, const bian &b) { return a.z < b.z; }
struct edge {
  int to, next, v;
} e[10 * 2005];
int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
void ins(int u, int v, int w) {
  e[++cnt].to = v;
  e[cnt].next = head[u];
  e[cnt].v = w;
  head[u] = cnt;
}
void insert(int u, int v, int w) {
  ins(u, v, w);
  ins(v, u, w);
}
void init() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
}
bool pre_judge() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if ((i == j) && (a[i][i] != 0)) return 0;
      if ((i != j) && (a[i][j] == 0)) return 0;
      if (a[i][j] != a[j][i]) return 0;
    }
  return 1;
}
void Kruskal() {
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i < j) {
        b[++tot].x = i;
        b[tot].y = j;
        b[tot].z = a[i][j];
      }
  sort(b + 1, b + tot + 1);
  int piece = n;
  for (int i = 1; i <= tot; i++) {
    int fx = getfa(b[i].x), fy = getfa(b[i].y);
    if (fx == fy) continue;
    piece--;
    fa[fx] = fy;
    insert(b[i].x, b[i].y, b[i].z);
    if (piece == 1) return;
  }
}
void dfs(int cur) {
  for (int i = head[cur]; i; i = e[i].next) {
    if (vis[e[i].to]) continue;
    for (int j = 1; j <= top; j++) {
      dist[e[i].to][zhan[j]] = dist[zhan[j]][cur] + e[i].v;
      dist[zhan[j]][e[i].to] = dist[zhan[j]][cur] + e[i].v;
    }
    zhan[++top] = e[i].to;
    vis[e[i].to] = 1;
    dfs(e[i].to);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  init();
  if (!pre_judge()) {
    printf("NO");
    return 0;
  }
  Kruskal();
  zhan[1] = 1;
  top = 1;
  vis[1] = 1;
  dfs(1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[i][j] != dist[i][j]) {
        printf("NO");
        return 0;
      }
  printf("YES");
  return 0;
}
