#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000;
int n, D[MAXN][MAXN];
template <int N, int M, class T>
struct LCA {
  std::vector<std::pair<int, T> > e[N];
  int d[N], p[N][M];
  T l[N];
  void init(int n) {
    for (int i = 0; i < n; ++i) {
      e[i].clear();
    }
  }
  void add(int u, int v, T w) {
    e[u].push_back(std::make_pair(v, w));
    e[v].push_back(std::make_pair(u, w));
  }
  void dfs(int u, int f) {
    p[u][0] = f;
    for (int i = 1; i < M; ++i) {
      p[u][i] = p[p[u][i - 1]][i - 1];
    }
    for (int i = 0; i < (int)e[u].size(); ++i) {
      int v = e[u][i].first;
      if (v != f) {
        d[v] = d[u] + 1;
        l[v] = l[u] + e[u][i].second;
        dfs(v, u);
      }
    }
  }
  int up(int u, int m) {
    for (int i = 0; i < M; ++i) {
      if ((m >> i) & 1) {
        u = p[u][i];
      }
    }
    return u;
  }
  int lca(int u, int v) {
    if (d[u] > d[v]) {
      std::swap(u, v);
    }
    v = up(v, d[v] - d[u]);
    if (u == v) {
      return u;
    } else {
      for (int i = M - 1; i >= 0; --i) {
        if (p[u][i] != p[v][i]) {
          u = p[u][i];
          v = p[v][i];
        }
      }
      return p[u][0];
    }
  }
  T howfar(int u, int v) {
    int w = lca(u, v);
    return l[u] + l[v] - 2 * l[w];
  }
  void build() {
    d[0] = l[0] = 0;
    dfs(0, 0);
  }
};
LCA<MAXN, 11, int> lca;
vector<pair<int, pair<int, int> > > V;
int P[MAXN];
int getp(int x) { return x == P[x] ? x : (P[x] = getp(P[x])); }
bool judge() {
  for (int i = 0; i < n; ++i) {
    if (D[i][i] != 0) {
      return false;
    }
    for (int j = i + 1; j < n; ++j) {
      if (D[i][j] != D[j][i]) {
        return false;
      }
      if (D[i][j] == 0) {
        return false;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      V.push_back(make_pair(D[i][j], make_pair(i, j)));
    }
  }
  sort(V.begin(), V.end());
  for (int i = 0; i < n; ++i) {
    P[i] = i;
  }
  lca.init(n);
  for (int i = 0; i < (int)V.size(); ++i) {
    int a = V[i].second.first;
    int b = V[i].second.second;
    int x = getp(a);
    int y = getp(b);
    if (x != y) {
      P[x] = y;
      lca.add(a, b, D[a][b]);
    }
  }
  for (int i = 1; i < n; ++i) {
    if (getp(0) != getp(i)) {
      return false;
    }
  }
  lca.build();
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (lca.howfar(i, j) != D[i][j]) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &D[i][j]);
    }
  }
  puts(judge() ? "YES" : "NO");
  return 0;
}
