#include <bits/stdc++.h>
using namespace std;
const int MN = 2011;
int lab[MN], d[MN][MN], n, nEdges;
pair<int, pair<int, int> > edges[MN * MN];
vector<pair<int, int> > ke[MN];
void init() {
  for (int i = (1), _b = (n); i <= _b; ++i) ke[i].clear();
  memset(lab, -1, sizeof lab);
  nEdges = 0;
}
int getRoot(int u) {
  if (lab[u] < 0) return u;
  return lab[u] = getRoot(lab[u]);
}
void merge(int u, int v) {
  u = getRoot(u);
  v = getRoot(v);
  if (u == v) return;
  if (lab[u] > lab[v]) swap(u, v);
  lab[u] += lab[v];
  lab[v] = u;
}
int visited[MN];
void dfs(int u, int fu) {
  for (int i = (0), _b = (-1 + ke[u].size()); i <= _b; ++i) {
    int v = ke[u][i].first;
    if (v == fu) continue;
    visited[v] = visited[u] + ke[u][i].second;
    dfs(v, u);
  }
}
int main() {
  ios ::sync_with_stdio(false);
  while (cin >> n) {
    init();
    bool ok = true;
    for (int i = (1), _b = (n); i <= _b; ++i)
      for (int j = (1), _b = (n); j <= _b; ++j) {
        cin >> d[i][j];
        if (i != j && !d[i][j]) ok = false;
      }
    if (!ok) {
      cout << "NO" << endl;
      continue;
    }
    nEdges = 0;
    for (int i = (1), _b = (n); i <= _b; ++i)
      for (int j = (i + 1), _b = (n); j <= _b; ++j) {
        ++nEdges;
        edges[nEdges] = make_pair(d[i][j], make_pair(i, j));
      }
    sort(edges + 1, edges + nEdges + 1);
    for (int i = (1), _b = (nEdges); i <= _b; ++i) {
      int u = edges[i].second.first, v = edges[i].second.second;
      if (getRoot(u) == getRoot(v)) continue;
      merge(u, v);
      ke[u].push_back(make_pair(v, edges[i].first));
      ke[v].push_back(make_pair(u, edges[i].first));
    }
    for (int i = (1), _b = (n); i <= _b; ++i) {
      memset(visited, 0, sizeof visited);
      dfs(i, -1);
      for (int j = (1), _b = (n); j <= _b; ++j)
        if (visited[j] != d[i][j]) ok = false;
    }
    if (ok)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
  return 0;
}
