#include <bits/stdc++.h>
using namespace std;
const int maxn = 4 * 1000 * 1000 + 10, maxm = 2 * 1000 + 10;
int n, par[maxm], f[maxm][maxm];
long long dis[maxm][maxm];
bool flg;
pair<int, pair<int, int> > d[maxn];
vector<pair<int, int> > vec[maxm];
void dfs(int x, int index, int p) {
  if (dis[index][x] != f[index][x]) flg = 1;
  for (int i = 0; i < ((int(vec[x].size()))); i++) {
    if (vec[x][i].first != p) {
      dis[index][vec[x][i].first] = dis[index][x] + vec[x][i].second;
      dfs(vec[x][i].first, index, x);
    }
  }
}
int fnd(int x) {
  if (par[x] == x) return x;
  return par[x] = fnd(par[x]);
}
bool mrg(int x, int y) {
  x = fnd(x);
  y = fnd(y);
  if (x == y) return 0;
  par[y] = x;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n * n; i++) {
    scanf("%d", &d[i].first);
    d[i].second.first = i / n;
    d[i].second.second = i % n;
    f[i / n][i % n] = d[i].first;
    if (i / n != i % n && f[i / n][i % n] == 0) flg = 1;
  }
  if (flg) {
    printf("NO");
    return 0;
  }
  sort(d, d + (n * n));
  for (int i = 1; i < n; i++) par[i] = i;
  for (int i = 0; i < n * n; i++) {
    if (mrg(d[i].second.first, d[i].second.second)) {
      vec[d[i].second.first].push_back(
          make_pair(d[i].second.second, d[i].first));
      vec[d[i].second.second].push_back(
          make_pair(d[i].second.first, d[i].first));
    }
  }
  for (int i = 0; i < n; i++) {
    dfs(i, i, -1);
    if (flg) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
