#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
long long mod = 1e9 + 7;
const int MX = 2e3 + 5;
const int MXX = 4e6 + 5;
const int LOGN = 20;
int parent[MX];
int findp(int u) { return parent[u] = (parent[u] == u ? u : findp(parent[u])); }
int d[MX][MX], a[MXX], b[MXX], c[MXX], h[MXX];
vector<int> adj[MX];
long long cost[MX];
int sp[12][MX], lev[MX];
void dfs(int u = 1, int p = 0, long long cs = 0) {
  sp[0][u] = p;
  lev[u] = 1 + lev[p];
  cost[u] = cs;
  for (int i = 0; i < ((int)(adj[u]).size()); i += 2) {
    int v = adj[u][i];
    int t = adj[u][i | 1];
    if (v != p) dfs(v, u, cs + t);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> d[i][j];
      if (i == j and d[i][j]) {
        cout << "NO\n";
        return 0;
      }
      if (i != j and d[i][j] == 0) {
        cout << "NO\n";
        return 0;
      }
    }
    parent[i] = i;
  }
  int k = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (d[i][j] != d[j][i]) {
        cout << "NO\n";
        return 0;
      }
      a[k] = i, b[k] = j, c[k] = d[i][j], h[k] = k, k++;
    }
  }
  sort(h, h + k, [=](int i, int j) { return c[i] < c[j]; });
  int ed_cnt = 0;
  for (int i = 0; i < k and ed_cnt < n - 1; i++) {
    int u = a[h[i]], v = b[h[i]], t = c[h[i]];
    int x = u, y = v;
    u = findp(u), v = findp(v);
    if (u != v) {
      ed_cnt++;
      adj[x].push_back(y);
      adj[y].push_back(x);
      adj[x].push_back(t);
      adj[y].push_back(t);
      parent[u] = v;
    }
  }
  if (ed_cnt < n - 1) {
    cout << "NO\n";
    return 0;
  }
  dfs();
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 1; i <= n; i++) {
      sp[j][i] = sp[j - 1][sp[j - 1][i]];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int u = i, v = j;
      if (lev[u] > lev[v]) swap(u, v);
      if (lev[v] > lev[u])
        for (int k = floor(log2(lev[v] - lev[u])); k >= 0; k--)
          if (lev[sp[k][v]] >= lev[u]) v = sp[k][v];
      if (u != v) {
        for (int k = floor(log2(lev[v])); k >= 0; k--)
          if (sp[k][v] != sp[k][u]) u = sp[k][u], v = sp[k][v];
        v = u = sp[0][u];
      }
      long long t = cost[i] + cost[j] - 2 * cost[u];
      if (t != d[i][j]) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
