#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2000;
int N;
long long G[Maxn + 5][Maxn + 5];
bool PreCheck() {
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      if (i == j && G[i][j] != 0) return false;
      if (i != j && G[i][j] == 0) return false;
      if (G[i][j] != G[j][i]) return false;
    }
  return true;
}
struct DSU {
  int fa[Maxn + 5];
  void init(int n) {
    for (int i = 1; i <= n; i++) fa[i] = i;
  }
  int find(int u) {
    if (u == fa[u]) return fa[u];
    return fa[u] = find(fa[u]);
  }
  bool same(int u, int v) { return find(u) == find(v); }
  void merge(int u, int v) {
    if (same(u, v)) return;
    fa[find(u)] = find(v);
  }
};
struct Edge {
  int from, to;
  long long dis;
  bool operator<(const Edge &rhs) const { return dis < rhs.dis; }
};
vector<pair<int, long long> > g[Maxn + 5];
void addedge(int u, int v, long long dis) {
  g[u].push_back(make_pair(v, dis));
  g[v].push_back(make_pair(u, dis));
}
vector<Edge> e;
DSU s;
void Kruskal() {
  for (int i = 1; i <= N; i++)
    for (int j = i + 1; j <= N; j++) e.push_back(Edge{i, j, G[i][j]});
  sort(e.begin(), e.end()), s.init(N);
  for (int i = 0; i < (int)e.size(); i++) {
    int u = e[i].from, v = e[i].to;
    if (s.same(u, v)) continue;
    s.merge(u, v);
    addedge(u, v, e[i].dis);
  }
}
long long dis[Maxn + 5][Maxn + 5];
vector<int> vis;
void DFS(int u, int fa) {
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i].first;
    if (v == fa) continue;
    for (int j = 0; j < (int)vis.size(); j++)
      dis[vis[j]][v] = dis[v][vis[j]] = dis[u][vis[j]] + g[u][i].second;
    vis.push_back(v);
    DFS(v, u);
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) scanf("%lld", &G[i][j]);
  if (PreCheck() == false) {
    puts("NO");
    return 0;
  }
  Kruskal();
  vis.push_back(1);
  DFS(1, -1);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (dis[i][j] != G[i][j]) {
        puts("NO");
        return 0;
      }
  puts("YES");
  return 0;
}
