#include <bits/stdc++.h>
using namespace std;
long long dist[2010][2010];
long long N;
bool basic() {
  for (long long i = 0; i < N; i++) {
    if (dist[i][i] != 0) return false;
    for (long long j = i + 1; j < N; j++) {
      if (dist[i][j] != dist[j][i]) return false;
      if (dist[i][j] <= 0) return false;
    }
  }
  return true;
}
vector<long long> inferiores[2010];
vector<long long> peso[2010];
vector<long long> adj[2010];
long long nodes[2010];
bool compara(const long long &a, const long long &b) {
  return inferiores[a].size() < inferiores[b].size();
}
bool used[2010];
bool vis[2010];
long long d[2010];
void dfs(long long u, long long acum = 0) {
  d[u] = acum;
  vis[u] = true;
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (!vis[v]) {
      dfs(v, acum + peso[u][i]);
    }
  }
}
bool comprobar(long long root) {
  for (long long i = 0; i < 2010; i++) {
    vis[i] = false;
  }
  dfs(root);
  for (long long i = 0; i < N; i++) {
    if (d[i] != dist[i][root]) {
      return false;
    }
  }
  return true;
}
void doit() {
  scanf("%lld", &N);
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      long long num;
      scanf("%lld", &num);
      dist[i][j] = num;
    }
    nodes[i] = i;
  }
  if (!basic()) {
    printf("NO\n");
    return;
  }
  for (long long i = 1; i < N; i++) {
    for (long long j = 1; j < N; j++) {
      if (i == j) continue;
      if (dist[0][i] - dist[i][j] == dist[0][j]) {
        inferiores[j].push_back(i);
      }
    }
    inferiores[0].push_back(i);
  }
  sort(nodes, nodes + N, compara);
  for (long long i = 0; i < N; i++) {
    long long u = nodes[i];
    for (long long i = 0; i < inferiores[u].size(); i++) {
      long long v = inferiores[u][i];
      if (used[v]) continue;
      adj[u].push_back(v);
      adj[v].push_back(u);
      peso[u].push_back(dist[u][v]);
      peso[v].push_back(dist[u][v]);
      used[v] = true;
    }
  }
  for (long long u = 0; u < N; u++) {
    if (!comprobar(u)) {
      printf("NO\n");
      return;
    }
  }
  printf("YES\n");
}
int main() {
  long long T = 1;
  while (T--) doit();
  return 0;
}
