#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > adj[2005];
long long c[2005][2005];
long long vis[2005];
void dfs(long long s, long long u) {
  vis[u] = 1;
  for (auto x : adj[u]) {
    if (!vis[x.first]) {
      c[s][x.first] = c[s][u] + x.second;
      dfs(s, x.first);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  long long n;
  cin >> n;
  long long a[n + 1][n + 1];
  long long ok = 1;
  for (long long i = 1; i < n + 1; i++)
    for (long long j = 1; j < n + 1; j++) cin >> a[i][j];
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < n + 1; j++) {
      if (a[i][i] != 0) ok = 0;
      if (a[i][j] != a[j][i]) ok = 0;
      if (i != j && a[i][j] == 0) ok = 0;
    }
  }
  if (!ok) {
    cout << "NO";
    return 0;
  }
  long long set[n + 1], par[n + 1];
  for (long long i = 1; i < n + 1; i++) {
    set[i] = 1e10;
    par[i] = i;
    vis[i] = 0;
  }
  set[1] = 0;
  for (long long i = 0; i < n - 1; i++) {
    long long umin = 1e11, u;
    for (long long j = 1; j <= n; j++) {
      if (umin > set[j] && !vis[j]) umin = set[j], u = j;
    }
    vis[u] = 1;
    for (long long j = 1; j <= n; j++) {
      if (!vis[j] && set[j] > a[u][j]) {
        par[j] = u;
        set[j] = a[u][j];
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    long long u = i, v = par[i];
    if (par[i] != i) {
      adj[i].push_back({par[i], a[i][par[i]]});
      adj[par[i]].push_back({i, a[i][par[i]]});
    }
  }
  for (long long i = 0; i < n + 1; i++)
    for (long long j = 0; j < n + 1; j++) c[i][j] = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) vis[j] = 0;
    dfs(i, i);
  }
  for (long long i = 1; i < n + 1; i++)
    for (long long j = 1; j < n + 1; j++)
      if (a[i][j] != c[i][j]) ok = 0;
  if (ok)
    cout << "YES";
  else
    cout << "NO";
}
