#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
int n, a[N][N], m, b[N], v[N], True;
pair<int, int> p[N * N];
vector<int> e[N], w[N];
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  return a[p1.first][p1.second] < a[p2.first][p2.second];
}
int f(int i) {
  if (b[i] == i) return i;
  return b[i] = f(b[i]);
}
bool ok(int u, int d) {
  if (a[True][u] != d) return false;
  v[u] = True;
  int i, j, sz = e[u].size();
  for (j = 0; j < sz; j++) {
    i = e[u][j];
    if (v[i] == True) continue;
    if (!ok(i, d + w[u][j])) return false;
  }
  return true;
}
int main() {
  int i, j, k, x, y;
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
    }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j && a[i][j] != 0) {
        printf("NO\n");
        return 0;
      }
      if (i != j && a[i][j] == 0) {
        printf("NO\n");
        return 0;
      }
      if (a[i][j] != a[j][i]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      p[m++] = make_pair(i, j);
    }
  }
  sort(p, p + m, cmp);
  for (i = 1; i <= n; i++) b[i] = i;
  for (i = 0; i < m; i++) {
    j = p[i].first;
    k = p[i].second;
    x = f(j);
    y = f(k);
    if (x == y) continue;
    if (rand() & 1) swap(x, y);
    b[x] = y;
    e[j].push_back(k);
    w[j].push_back(a[j][k]);
    e[k].push_back(j);
    w[k].push_back(a[j][k]);
  }
  for (i = 1; i <= n; i++) {
    True++;
    if (!ok(i, 0)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
