#include <bits/stdc++.h>
using namespace std;
const int N = 2222;
int f[N][N];
int d[N], u[N], p[N];
void no() {
  puts("NO");
  exit(0);
}
int a[N][N];
vector<int> g[N];
vector<int> gw[N];
void dfs(int i, int* a, int p = -1, int d = 0) {
  a[i] = d;
  for (int k = 0; k < g[i].size(); ++k) {
    int j = g[i][k];
    if (j == p) continue;
    dfs(j, a, i, d + gw[i][k]);
  }
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &f[i][j]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (f[i][i]) no();
      if (i != j && !f[i][j]) no();
      if (f[i][j] != f[j][i]) no();
    }
  int inf = 1e9 + 9;
  fill(d, d + n + 1, inf);
  fill(p, p + n + 1, -1);
  d[0] = 0;
  for (;;) {
    int i = n;
    for (int j = 0; j < n; ++j)
      if (!u[j] && d[i] > d[j]) i = j;
    if (d[i] >= inf) break;
    u[i] = 1;
    for (int j = 0; j < n; ++j)
      if (!u[j]) {
        if (d[j] > f[i][j]) {
          d[j] = f[i][j];
          p[j] = i;
        }
      }
  }
  for (int i = 1; i < n; ++i) {
    int j = p[i];
    g[i].push_back(j);
    gw[i].push_back(f[i][j]);
    g[j].push_back(i);
    gw[j].push_back(f[i][j]);
  }
  for (int i = 0; i < n; ++i) dfs(i, a[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (a[i][j] != f[i][j]) no();
  cout << "YES" << endl;
  return 0;
}
