#include <bits/stdc++.h>
using namespace std;
int grid[2000][2000];
vector<pair<int, int> > g[2000];
long long dist[2000][2000];
int n;
int p[2000];
vector<pair<int, pair<int, int> > > edges;
int fin(int x) {
  if (x == p[x])
    return x;
  else
    return p[x] = fin(p[x]);
}
void uni(int x, int y) { p[fin(x)] = p[fin(y)]; }
void dfs(int root, int parent, int u) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].second;
    int dv = g[u][i].first;
    if (v == parent) continue;
    dist[root][v] = dist[root][u] + dv;
    dfs(root, u, v);
  }
}
void solve() {
  sort(edges.begin(), edges.end());
  memset(dist, 0, sizeof(dist));
  for (int i = 0; i < n; i++) p[i] = i;
  for (int i = 0; i < edges.size(); i++) {
    int u = edges[i].second.first;
    int v = edges[i].second.second;
    int d = edges[i].first;
    if (fin(u) != fin(v)) {
      uni(u, v);
      g[u].push_back(make_pair(d, v));
      g[v].push_back(make_pair(d, u));
    }
  }
  bool ok = true;
  for (int i = 0; i < n; i++) {
    dfs(i, -1, i);
    for (int v = 0; v < n; v++) ok &= grid[i][v] == dist[i][v];
    if (!ok) break;
  }
  puts((ok) ? "YES" : "NO");
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &grid[i][j]);
    }
  bool poss = true;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      poss &= grid[i][j] == grid[j][i];
      poss &= !grid[j][j];
      if (grid[i][j]) edges.push_back(make_pair(grid[i][j], make_pair(i, j)));
    }
  poss &= edges.size() >= n - 1;
  if (!poss)
    cout << "NO\n";
  else
    solve();
  return 0;
}
