#include <bits/stdc++.h>
using namespace std;
int mmap[2005][2005];
int nmap[2005][2005];
struct node {
  int u, v, w;
} wei[4000005];
int neiu[2005], neiv[2005];
int cmp(node a, node b) { return a.w < b.w; }
int main() {
  int i1, i2, i3, edn, j1, j2;
  int n;
  scanf("%d", &n);
  for (i1 = 0; i1 < n; i1++) {
    for (i2 = 0; i2 < n; i2++) {
      scanf("%d", &mmap[i1][i2]);
    }
  }
  edn = 0;
  for (i1 = 0; i1 < n; i1++) {
    if (mmap[i1][i1] != 0) {
      break;
    }
    for (i2 = i1 + 1; i2 < n; i2++) {
      if (mmap[i1][i2] != mmap[i2][i1] || mmap[i1][i2] == 0) {
        break;
      }
      wei[edn].u = i1;
      wei[edn].v = i2;
      wei[edn].w = mmap[i1][i2];
      edn++;
    }
    if (i2 < n && i1 < n - 1) {
      break;
    }
  }
  if (i1 < n) {
    printf("NO\n");
    return 0;
  }
  sort(wei, wei + edn, cmp);
  memset(nmap, -1, sizeof(nmap));
  for (i1 = 0; i1 < n; i1++) {
    nmap[i1][i1] = 0;
  }
  for (i1 = 0; i1 < edn; i1++) {
    if (nmap[wei[i1].u][wei[i1].v] == -1) {
      j1 = j2 = 0;
      for (i2 = 0; i2 < n; i2++) {
        if (nmap[wei[i1].u][i2] != -1) {
          neiu[j1] = i2;
          j1++;
        }
        if (nmap[wei[i1].v][i2] != -1) {
          neiv[j2] = i2;
          j2++;
        }
      }
      for (i2 = 0; i2 < j1; i2++) {
        for (i3 = 0; i3 < j2; i3++) {
          nmap[neiu[i2]][neiv[i3]] =
              nmap[neiu[i2]][wei[i1].u] + wei[i1].w + nmap[wei[i1].v][neiv[i3]];
          nmap[neiv[i3]][neiu[i2]] =
              nmap[neiu[i2]][wei[i1].u] + wei[i1].w + nmap[wei[i1].v][neiv[i3]];
        }
      }
    } else {
      if (nmap[wei[i1].u][wei[i1].v] != wei[i1].w) {
        break;
      }
    }
  }
  if (i1 < edn) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }
  return 0;
}
