#include <bits/stdc++.h>
using namespace std;
const int N = (int)2000 + 99;
const int K = 12;
struct edge {
  int u, v, w;
};
int par[N], Size[N];
vector<long long> d;
vector<pair<int, int>> g[N];
bool cmp(edge a, edge b) { return a.w < b.w; }
int find_set(int v) { return par[v] = par[v] == v ? v : find_set(par[v]); }
void dfs(int v, int p, int w = 0) {
  d[v] = d[p] + w;
  for (auto e : g[v])
    if (p - e.first) dfs(e.first, v, e.second);
}
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 2][n + 2];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
  if (n == 1 && a[1][1] == 0) return puts("YES"), 0;
  for (int i = 1; i <= n; ++i) par[i] = i, Size[i] = 1;
  bool ok = true;
  vector<edge> Edge;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (!a[i][j]) continue;
      if (i == j || a[i][j] - a[j][i]) ok = false;
      if (i < j) Edge.push_back({i, j, a[i][j]});
    }
  }
  if (!ok || Edge.empty()) return puts("NO"), 0;
  sort(Edge.begin(), Edge.end(), cmp);
  for (auto e : Edge) {
    int u = find_set(e.u);
    int v = find_set(e.v);
    if (u - v) {
      if (Size[u] < Size[v]) swap(u, v);
      par[v] = u;
      Size[u] += Size[v];
      g[e.u].push_back({e.v, e.w});
      g[e.v].push_back({e.u, e.w});
    }
  }
  for (int i = 1; i <= n; ++i) {
    d.assign(n + 1, 0);
    dfs(i, i);
    for (int j = 1; j <= n; ++j)
      if (a[i][j] - d[j]) ok = false;
  }
  if (ok)
    puts("YES");
  else
    puts("NO");
  return 0;
}
