#include <bits/stdc++.h>
using namespace std;
int p[2001][2001];
int first[2001];
int dp[2001];
int dis[2001];
int o[2001];
int s[2001];
int t;
struct node {
  int u, v, w, next;
} edge[2001 * 2001];
void CL() {
  t = 0;
  memset(first, -1, sizeof(first));
}
void add(int u, int v, int w) {
  edge[t].u = u;
  edge[t].v = v;
  edge[t].w = w;
  edge[t].next = first[u];
  first[u] = t++;
}
void dfs(int x, int sum) {
  int v, i;
  o[x] = 1;
  for (i = first[x]; i != -1; i = edge[i].next) {
    v = edge[i].v;
    if (o[v]) continue;
    dp[v] = sum + edge[i].w;
    dfs(v, sum + edge[i].w);
  }
}
int main() {
  int n, i, j, flag, k, minz;
  scanf("%d", &n);
  CL();
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) scanf("%d", &p[i][j]);
  }
  flag = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j) {
        if (p[i][j] != 0) flag = 1;
      } else {
        if (p[i][j] != p[j][i]) flag = 1;
      }
    }
    if (flag) break;
  }
  if (flag) {
    printf("NO\n");
    return 0;
  }
  for (i = 1; i <= n; i++) {
    dis[i] = p[1][i];
    s[i] = 1;
  }
  o[1] = 1;
  for (i = 1; i < n; i++) {
    minz = 1000000001;
    for (j = 1; j <= n; j++) {
      if (minz > dis[j] && !o[j]) {
        minz = dis[j];
        k = j;
      }
    }
    if (minz == 0) {
      flag = 1;
      break;
    }
    add(s[k], k, minz);
    add(k, s[k], minz);
    o[k] = 1;
    for (j = 1; j <= n; j++) {
      if (!o[j] && p[k][j] < dis[j]) {
        dis[j] = p[k][j];
        s[j] = k;
      }
    }
  }
  if (flag) {
    printf("NO\n");
    return 0;
  }
  for (i = 1; i <= n; i++) {
    memset(o, 0, sizeof(o));
    memset(dp, 0, sizeof(dp));
    dfs(i, 0);
    for (j = 0; j < n; j++) {
      if (p[i][j] != dp[j]) {
        flag = 1;
        break;
      }
    }
    if (flag) break;
  }
  if (flag) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }
  return 0;
}
