#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> grid(2001, vector<long long>(2001, 0));
class dsu {
 public:
  long long n;
  vector<long long> par;
  dsu(long long N) {
    n = N;
    par = vector<long long>(n, 0);
    for (long long i = 0; i < n; ++i) par[i] = i;
  }
  long long get_super_parent(long long x) {
    if (par[x] != x) par[x] = get_super_parent(par[x]);
    return par[x];
  }
  bool same(long long a, long long b) {
    return get_super_parent(a) == get_super_parent(b);
  }
  void merge(long long a, long long b) {
    long long p1 = get_super_parent(a);
    long long p2 = get_super_parent(b);
    par[p1] = p2;
  }
};
bool preliminaryTest(vector<vector<long long>> &grid, long long n) {
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      if (i == j) {
        if (grid[i][j] != 0) return false;
      } else {
        if (grid[i][j] == 0 || grid[i][j] != grid[j][i]) return false;
      }
    }
  }
  return true;
}
vector<pair<long long, long long>> adj[2001];
bool comparator(vector<long long> &a, vector<long long> &b) {
  return a[0] < b[0];
}
void constructTree(long long n) {
  vector<vector<long long>> s;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      vector<long long> temp(3, 0);
      temp = {grid[i][j], i, j};
      s.push_back(temp);
    }
  }
  sort(s.begin(), s.end(), comparator);
  long long edge = 0;
  dsu d(n);
  for (auto x : s) {
    if (edge == n - 1) {
      break;
    }
    if (!d.same(x[1], x[2])) {
      long long u = x[1];
      long long v = x[2];
      adj[u].push_back({v, x[0]});
      adj[v].push_back({u, x[0]});
      d.merge(u, v);
      edge++;
    }
  }
}
void dfs(long long node, long long par, long long og, long long dist,
         bool *flag, long long *visited) {
  (*visited)++;
  if (dist != grid[node][og]) (*flag) = false;
  for (auto child : adj[node]) {
    if (child.first == par) continue;
    dfs(child.first, node, og, dist + child.second, flag, visited);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      cin >> grid[i][j];
    }
  }
  bool flag = preliminaryTest(grid, n);
  if (flag == false) {
    cout << "NO";
    return 0;
  }
  constructTree(n);
  flag = true;
  for (long long i = 0; i < n; ++i) {
    long long visited = 0;
    dfs(i, i, i, 0, &flag, &visited);
    if (visited != n || flag == false) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << endl;
}
