#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> edge[2005];
long long c[2005][2005], a[2005], dis[2005][2005], vis[2005];
void dfs(long long u, long long fa, long long k, long long d) {
  dis[k][u] = d;
  for (auto v : edge[u]) {
    if (v.first == fa) continue;
    dfs(v.first, u, k, d + v.second);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%lld", &c[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (c[i][i] != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (i != j && c[i][j] == 0) {
        cout << "NO" << endl;
        return 0;
      }
      if (c[i][j] != c[j][i]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    a[i] = 1;
  }
  vis[1] = 1;
  for (long long i = 1; i <= n; i++) {
    long long mi = 2e9, x = 0;
    for (long long j = 1; j <= n; j++) {
      if (vis[j]) continue;
      if (c[a[j]][j] != 0 && mi > c[a[j]][j]) {
        mi = c[a[j]][j];
        x = j;
      }
    }
    if (!x) break;
    vis[x] = 1;
    edge[a[x]].push_back({x, mi});
    edge[x].push_back({a[x], mi});
    for (long long j = 1; j <= n; j++) {
      if (vis[j]) continue;
      if (c[a[j]][j] > c[x][j] && c[x][j] > 0) {
        a[j] = x;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    dfs(i, 0, i, 0);
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (c[i][j] != dis[i][j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}
