#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int root;
int n, k;
vector<pair<int, pair<int, int> > > by;
int F[4005], f[4005];
long long d[4005];
int mp[2002][2002];
vector<pair<int, int> > eg[4005];
int ba(int k) {
  if (k != F[k]) F[k] = ba(F[k]);
  return F[k];
}
void dfs(int rt, long long dp) {
  d[rt] = dp;
  for (int i = 0; i < eg[rt].size(); i++)
    if (f[rt] != eg[rt][i].second) {
      f[eg[rt][i].second] = rt;
      dfs(eg[rt][i].second, dp + eg[rt][i].first);
    }
}
int main() {
  scanf("%d", &n);
  int NO = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &mp[i][j]);
      if (i != j && mp[i][j] == 0) NO = 1;
      if (i == j && mp[i][j] != 0) NO = 1;
      if (i > j && mp[i][j] != mp[j][i]) NO = 1;
    }
  if (NO) {
    printf("NO\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++)
      by.push_back(pair<int, pair<int, int> >(mp[i][j], pair<int, int>(i, j)));
  sort(by.begin(), by.end());
  for (int i = 1; i <= n; i++) F[i] = i;
  int E = 0;
  for (int i = 0; E < n - 1 && i < by.size(); i++) {
    int w = by[i].first;
    pair<int, int> p = by[i].second;
    int u = p.first, v = p.second;
    u = ba(u), v = ba(v);
    if (u == v) continue;
    F[u] = v;
    eg[p.first].push_back(pair<int, int>(w, p.second));
    eg[p.second].push_back(pair<int, int>(w, p.first));
    E++;
  }
  for (int i = 1; !NO && i <= n; i++) {
    root = i;
    memset(f, 0, sizeof(f));
    memset(d, 0, sizeof(d));
    dfs(root, 0);
    for (int j = 1; !NO && j <= n; j++)
      if (d[j] != mp[root][j] || d[j] != mp[j][root]) NO = 1;
  }
  if (NO)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
