#include <bits/stdc++.h>
using namespace std;
const int MX = 2000;
const int LG = 12;
int g[MX + 5][MX + 5], lbl[MX + 5], sp[MX + 5][LG + 2];
int cost[MX + 5], bos[MX + 5], n, cnt;
vector<pair<int, pair<int, int>>> v;
vector<pair<int, int>> ad[MX + 5];
int F_boss(int a) {
  if (bos[a] == a)
    return a;
  else
    return bos[a] = F_boss(bos[a]);
}
void mst() {
  for (int i = 0; i < v.size(); i++) {
    int c = v[i].first;
    int a = v[i].second.first;
    int b = v[i].second.second;
    int x = F_boss(a);
    int y = F_boss(b);
    if (x != y) {
      bos[x] = y;
      ad[a].push_back({b, c});
      ad[b].push_back({a, c});
    }
  }
}
void dfs(int x, int p) {
  lbl[x] = lbl[p] + 1;
  cnt++;
  sp[x][0] = p;
  for (auto pr : ad[x]) {
    if (pr.first == p) continue;
    dfs(pr.first, x);
  }
}
void dfs1(int x, int p, int c) {
  cost[x] = c;
  for (auto pr : ad[x]) {
    if (pr.first == p) continue;
    dfs1(pr.first, x, c + pr.second);
  }
}
void SPTBL() {
  for (int j = 1; (1 << j) <= n; j++) {
    for (int i = 1; i <= n; i++) {
      if (sp[i][j - 1] == -1) continue;
      sp[i][j] = sp[sp[i][j - 1]][j - 1];
    }
  }
}
int lca(int x, int y) {
  if (lbl[x] < lbl[y]) swap(x, y);
  int dist = lbl[x] - lbl[y];
  for (int i = LG; i >= 0; i--) {
    if ((1 << i) <= dist) {
      x = sp[x][i];
      dist -= (1 << i);
    }
  }
  if (x == y) return x;
  for (int i = LG; i >= 0; i--) {
    if (sp[x][i] != sp[y][i] && sp[x][i] != -1) {
      x = sp[x][i];
      y = sp[y][i];
    }
  }
  return sp[x][0];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    bos[i] = i;
    for (int j = 1; j <= n; j++) {
      cin >> g[i][j];
      if (g[i][j] && i != j) v.push_back({g[i][j], {i, j}});
    }
  }
  sort(v.begin(), v.end());
  mst();
  memset(sp, -1, sizeof(sp));
  dfs(1, 0);
  SPTBL();
  dfs1(1, 0, -1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int lc = lca(i, j);
      int lcacost = cost[i] + cost[j] - 2 * cost[lc];
      if (lcacost != g[i][j] || cnt != n) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
