#include <bits/stdc++.h>
using namespace std;
std::vector<int> g[2002];
bool vis[2001];
int p[2001][2001];
int fa[2001];
int findRoot(int u) { return fa[u] < 0 ? u : fa[u] = findRoot(fa[u]); }
bool k;
void dfs(int i, int u, int d, int dis) {
  if (dis != p[i][u] && !k) {
    cout << "NO";
    k = 1;
  }
  for (auto v : g[u]) {
    if (v != d) dfs(i, v, u, dis + p[u][v]);
  }
}
int main() {
  std::vector<pair<int, pair<int, int> > > v;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int x;
      scanf("%d", &x);
      if (x) {
        if (i < j) {
          v.push_back(make_pair(x, make_pair(i + 1, j + 1)));
          p[i + 1][j + 1] = x;
          p[j + 1][i + 1] = x;
        } else if (i > j)
          if (p[j + 1][i + 1] != x) {
            cout << "NO";
            return 0;
          }
      }
      if (i == j && x != 0) {
        cout << "NO";
        return 0;
      }
      if (x == 0 && i != j) {
        cout << "NO";
        return 0;
      }
    }
  }
  sort(v.begin(), v.end());
  memset(fa, -1, sizeof(fa));
  for (int i = 0; i < v.size(); i++) {
    int x, y;
    int r1 = findRoot(x = v[i].second.first);
    int r2 = findRoot(y = v[i].second.second);
    if (r1 != r2) {
      g[x].push_back(y);
      g[y].push_back(x);
      if (fa[r1] > fa[r2]) {
        fa[r1] = r2;
        fa[r2] = -1;
      } else {
        fa[r2] = r1;
        fa[r1] = -1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    dfs(i + 1, i + 1, 0, 0);
  }
  if (!k) cout << "YES";
  return 0;
}
