#include <bits/stdc++.h>
using namespace std;
const int N = 2008;
int n, m, fa[N], d[N][N], Map[N][N], tot, head[N], TAK;
struct Edge {
  int u, v, w;
  bool operator<(const Edge &b) const { return w < b.w; }
  Edge(int _u = 0, int _v = 0, int _w = 0) { u = _u, v = _v, w = _w; }
} L[N * N];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
struct Node {
  int next, node, dist;
} e[N << 1];
inline void add(int x, int y, int z) {
  e[++tot].next = head[x], head[x] = tot, e[tot].node = y, e[tot].dist = z;
  e[++tot].next = head[y], head[y] = tot, e[tot].node = x, e[tot].dist = z;
}
void dfs(int S, int u, int FA) {
  for (int i = head[u], v; v = e[i].node, i; i = e[i].next)
    if (v != FA) {
      d[S][v] = d[S][u] + e[i].dist;
      dfs(S, v, u);
    }
}
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int w;
      scanf("%d", &w);
      Map[i][j] = w;
      if (i == j && w) {
        TAK = 0;
        return;
      }
      if (i != j && !w) {
        TAK = 0;
        return;
      }
      if (i != j) L[++m] = Edge(i, j, w);
    }
  sort(L + 1, L + m + 1);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int u = L[i].u, v = L[i].v;
    if (find(u) != find(v)) fa[find(u)] = find(v), add(u, v, L[i].w);
  }
  for (int i = 1; i <= n; i++) dfs(i, i, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (d[i][j] != Map[i][j]) {
        TAK = 0;
        break;
      }
    if (!TAK) break;
  }
}
int main() {
  scanf("%d", &n);
  TAK = 1;
  solve();
  printf("%s\n", TAK ? "YES" : "NO");
  return 0;
}
