#include <bits/stdc++.h>
const int inf = 0x7FFFFFFF;
using namespace std;
int dep[2014], shortcut[20][2014];
struct Edge {
  int u, v, w;
  bool operator<(const Edge &A) const { return w < A.w; }
} E[4000005];
int mp[2014][2014];
int fa[2014], d[2014];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
vector<int> G[2014], Q;
int get_lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  for (int i = 20 - 1; i >= 0; i--) {
    if (dep[a] - dep[b] >> i & 1) {
      a = shortcut[i][a];
    }
  }
  if (a == b) return a;
  for (int i = 20 - 1; i >= 0; i--) {
    if (shortcut[i][a] != shortcut[i][b]) {
      a = shortcut[i][a];
      b = shortcut[i][b];
    }
  }
  return shortcut[0][a];
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) scanf("%d", &mp[i][j]);
  int tot = 0;
  for (int i = 1; i <= N; i++)
    for (int j = i + 1; j <= N; j++) {
      E[tot].u = i;
      E[tot].v = j;
      E[tot].w = mp[i][j];
      tot++;
    }
  sort(E, E + tot);
  for (int i = 1; i <= N; i++) fa[i] = i;
  for (int i = 0; i < tot; i++) {
    int u = E[i].u;
    int v = E[i].v;
    if (find(u) != find(v)) {
      fa[find(u)] = find(v);
      G[u].push_back(v);
      G[u].push_back(E[i].w);
      G[v].push_back(u);
      G[v].push_back(E[i].w);
    }
  }
  int *parent = shortcut[0];
  d[1] = 0;
  parent[1] = -1;
  dep[1] = 0;
  Q.push_back(1);
  for (int head = 0; head < int(Q.size()); head++) {
    int u = Q[head];
    for (int i = 0; i < int(G[u].size()); i += 2) {
      int v = G[u][i];
      int w = G[u][i + 1];
      if (v != parent[u]) {
        parent[v] = u;
        dep[v] = dep[u] + 1;
        d[v] = d[u] + w;
        Q.push_back(v);
      }
    }
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= N; j++) {
      int &res = shortcut[i][j];
      res = shortcut[i - 1][j];
      if (~res) {
        res = shortcut[i - 1][res];
      }
    }
  }
  bool ok = true;
  int num = 0;
  for (int i = 1; i <= N; i++)
    if (fa[i] == i) num++;
  if (num > 1) ok = false;
  for (int u = 1; ok && u <= N; u++) {
    if (mp[u][u] != 0) ok = false;
    for (int v = u + 1; ok && v <= N; v++) {
      if (mp[u][v] != mp[v][u]) ok = false;
      if (mp[u][v] == 0) ok = false;
      int mid = get_lca(u, v);
      if (d[u] + d[v] - d[mid] * 2 != mp[u][v]) ok = false;
    }
  }
  puts(ok ? "YES" : "NO");
  return 0;
}
