#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e3 + 10;
vector<pair<int, int> > edge[maxn];
int G[maxn][maxn], vis[maxn], par[maxn], dis[maxn];
const long long inf = (long long)1e9 + 10;
long long d[maxn];
void dfs(int u, int fa, long long s) {
  d[u] = s;
  for (int i = 0; i < edge[u].size(); ++i) {
    int v = edge[u][i].first;
    if (v != fa) {
      dfs(v, u, s + edge[u][i].second);
    }
  }
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) scanf("%d", &G[i][j]);
    bool ok = 1;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (G[i][j] != G[j][i] || G[i][i] || (!G[i][j] && i != j)) ok = 0;
    for (int i = 1; i <= n; ++i) {
      dis[i] = G[1][i];
      par[i] = 1;
    }
    memset(vis, 0, sizeof(vis));
    vis[1] = 1;
    for (int i = 1; i < n; ++i) {
      int k;
      int mi = inf;
      for (int j = 1; j <= n; ++j) {
        if (dis[j] < mi && !vis[j]) {
          k = j;
          mi = dis[j];
        }
      }
      if (inf == mi) {
        ok = 0;
        break;
      }
      vis[k] = 1;
      for (int j = 1; j <= n; ++j) {
        if (!vis[j] && dis[j] > G[k][j]) dis[j] = G[k][j], par[j] = k;
      }
      edge[par[k]].push_back(make_pair(k, mi));
      edge[k].push_back(make_pair(par[k], mi));
    }
    for (int i = 1; i <= n; ++i) {
      memset(d, 0, sizeof(d));
      dfs(i, 0, 0);
      for (int j = 1; j <= n; ++j) {
        if (d[j] != G[i][j]) {
          ok = 0;
        }
      }
    }
    if (ok)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
