#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int n;
int a[2100][2100];
int b[2100][2100];
int depth[2100];
void find(int x, int f) {
  for (int i = 1; i <= n; i++) {
    if (b[x][i] > 0 && i != f) {
      depth[i] = depth[x] + b[x][i];
      find(i, x);
    }
  }
}
int d[2100];
int in[2100];
int k[2100];
void prim() {
  in[1] = 1;
  for (int i = 1; i <= n; i++) {
    d[i] = a[1][i];
    k[i] = 1;
  }
  for (int l = 1; l < n; l++) {
    int minn = 2000000000;
    int p = 0;
    for (int i = 1; i <= n; i++) {
      if (in[i] == 1) continue;
      if (d[i] < minn) {
        minn = d[i];
        p = i;
      }
    }
    b[p][k[p]] = b[k[p]][p] = a[p][k[p]];
    in[p] = 1;
    for (int i = 1; i <= n; i++) {
      if (in[i] == 0) {
        if (a[i][p] < d[i]) {
          d[i] = a[i][p];
          k[i] = p;
        }
      }
    }
  }
}
int fa[2100];
int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
void merge(int x, int y) { fa[find(x)] = find(y); }
int vis[2100];
int ans[2100][2100];
void dfs(int x, int f) {
  vis[x] = 1;
  for (int i = 1; i <= n; i++) {
    if (i == f) continue;
    if (b[x][i] > 0) {
      dfs(i, x);
      fa[i] = x;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 1) {
      ans[x][i] = ans[i][x] = find(i);
    }
  }
}
struct node {
  int x, y, w;
} s[4100000];
int m;
bool cmp(node a, node b) { return a.w < b.w; }
signed main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      if (i == j && a[i][j] > 0) {
        cout << "NO";
        return 0;
      }
      if (i != j && a[i][j] == 0) {
        cout << "NO";
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i][j] != a[j][i]) {
        cout << "NO";
        return 0;
      }
    }
  }
  prim();
  find(1, 0);
  for (int i = 1; i <= n; i++) fa[i] = i;
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int t = depth[i] + depth[j] - 2 * depth[ans[i][j]];
      if (t != a[i][j]) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
