#include <bits/stdc++.h>
char ch;
inline void read(int &x) {
  x = 0;
  ch = getchar();
  while (ch <= 32) ch = getchar();
  while (ch > 32) {
    x = x * 10 + ch - 48;
    ch = getchar();
  };
};
int n;
int d[2005][2005];
inline void die() {
  puts("NO");
  exit(0);
};
int s[2005 * 2005 * 2];
int *top;
inline int *alloc(int size) {
  top += size + 1;
  return top - (size + 1);
};
inline void solve(int *a, int n) {
  if (n == 1) return;
  int ti = rand() % n + 1;
  int tj = 0, mi = 1100000000;
  int i, j;
  int *Dx = d[a[ti]];
  for (i = 1; i <= n; i++) {
    if (i != ti && Dx[a[i]] < mi) mi = Dx[a[i]], tj = i;
  };
  int *b = alloc(n);
  int *Dy = d[a[tj]];
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    if (Dx[a[i]] == Dy[a[i]]) die();
    if (Dx[a[i]] < Dy[a[i]]) b[++cnt] = a[i];
  };
  int *b2 = b + cnt;
  int cnt2 = 0;
  for (i = 1; i <= n; i++) {
    if (Dx[a[i]] > Dy[a[i]]) b2[++cnt2] = a[i];
  };
  for (i = 1; i <= cnt; i++) {
    for (j = 1; j <= cnt2; j++) {
      int p = b[i], q = b2[j];
      if (1LL * Dx[p] + mi + Dy[q] != d[p][q]) die();
    };
  };
  solve(b, cnt);
  solve(b2, cnt2);
};
inline void solve() {
  int i;
  for (i = 1; i <= n; i++) {
    s[i] = i;
  };
  top = s + n + 1;
  solve(s, n);
};
int main() {
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", d[i] + j);
    };
  };
  for (i = 1; i <= n; i++)
    if (d[i][i] != 0) die();
  for (i = 1; i <= n; i++) {
    for (j = 1; j < i; j++) {
      if (d[i][j] == 0 || d[i][j] != d[j][i]) die();
    };
  };
  solve();
  puts("YES");
}
