#include <bits/stdc++.h>
using namespace std;
int r = 1, a[2003][2003];
vector<pair<int, int>> g[2003];
void dfs(int node, int root, int par, int weight = 0) {
  if (a[root][node] != weight) {
    r = 0;
    return;
  }
  for (pair<int, int> x : g[node])
    if (x.first != par) dfs(x.first, root, node, weight + x.second);
}
int fs(vector<int> &par, int x) {
  return par[x] == x ? x : par[x] = fs(par, par[x]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  r = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++)
      if (a[i][j] != a[j][i] || !a[i][j]) r = 0;
    if (a[i][i]) r = 0;
  }
  vector<pair<int, pair<int, int>>> el;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) el.push_back({a[i][j], {i, j}});
  sort(el.begin(), el.end());
  vector<int> par(n);
  for (int i = 0; i < n; i++) par[i] = i;
  for (int i = 0; i < el.size(); i++) {
    int x = el[i].second.first, y = el[i].second.second, w = el[i].first;
    int a = fs(par, x), b = fs(par, y);
    if (a != b) par[a] = b, g[x].push_back({y, w}), g[y].push_back({x, w});
  }
  for (int i = 0; i < n; i++) dfs(i, i, i);
  if (r)
    cout << "YES\n";
  else
    cout << "NO\n";
}
