#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const int mod = 1000000007;
using namespace std;
int n;
int g[2005][2005];
struct edge {
  int t;
  int w;
  edge() {}
  edge(int a, int b) {
    t = a;
    w = b;
  }
};
vector<edge> tree[2005];
int e[2005][2005];
bool vis[2005];
int cost[2005];
int tr[2005];
void prim(int u) {
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i <= n; i++) cost[i] = inf;
  tr[u] = 0;
  cost[u] = 0;
  int sum = 0;
  while (true) {
    int v = -1;
    for (int i = 1; i <= n; i++)
      if (vis[i] == false && (v == -1 || cost[i] < cost[v])) v = i;
    if (v == -1) break;
    vis[v] = true;
    tree[tr[v]].push_back(edge(v, cost[v]));
    tree[v].push_back(edge(tr[v], cost[v]));
    for (int i = 1; i <= n; i++) {
      if (vis[i] == false && cost[i] > g[v][i]) {
        cost[i] = g[v][i];
        tr[i] = v;
      }
    }
  }
}
vector<int> vec;
queue<int> que;
void bfs(int r) {
  e[0][0] = 0;
  e[r][r] = 0;
  vec.clear();
  while (!que.empty()) que.pop();
  que.push(r);
  vec.push_back(r);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    int len = tree[u].size();
    for (int i = 0; i < len; i++) {
      int v = tree[u][i].t;
      int w = tree[u][i].w;
      if (e[v][v] == 0) continue;
      que.push(v);
      e[v][v] = 0;
      int s = vec.size();
      for (int j = 0; j < s; j++) {
        e[vec[j]][v] = e[vec[j]][u] + w;
        e[v][vec[j]] = e[vec[j]][v];
      }
      vec.push_back(v);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &g[i][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      e[i][j] = inf;
      if ((i == j && g[i][j] != 0) || (i != j && g[i][j] == 0) ||
          (g[i][j] != g[j][i])) {
        printf("NO\n");
        return 0;
      }
    }
  }
  prim(1);
  bfs(1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (e[i][j] != g[i][j]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
  return 0;
}
