#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000 + 10;
int n, adj[MAXN][MAXN], par[MAXN], in = 0;
vector<pair<int, pair<int, int>>> edg;
vector<int> Matrix[MAXN], W[MAXN];
queue<pair<int, int>> S;
bool no, Color[MAXN];
void BFS(int p, int v, int Dis) {
  if (adj[p][v] != Dis) {
    no = true;
    return;
  }
  Color[v] = true;
  for (int i = 0; i < Matrix[v].size(); i++) {
    if (!Color[Matrix[v][i]]) S.push(make_pair(Matrix[v][i], Dis + W[v][i]));
  }
}
void clco() {
  for (int i = 1; i <= n; i++) Color[i] = false;
}
int root(int i) {
  if (par[i] == i) return i;
  par[i] = root(par[i]);
  return par[i];
}
bool merge(int a, int b, int w) {
  in++;
  if (root(a) == root(b)) {
    return false;
  } else {
    par[root(a)] = root(b);
    Matrix[a].push_back(b);
    W[a].push_back(w);
    Matrix[b].push_back(a);
    W[b].push_back(w);
    return true;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i <= n; i++) par[i] = i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> adj[i][j];
      if (j < i && adj[i][j] != adj[j][i]) no = true;
      if (i == j && adj[i][j] != 0) no = true;
      if (j != i && adj[i][j] == 0) no = true;
    }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      edg.push_back(make_pair(adj[i][j], make_pair(i, j)));
  sort(edg.begin(), edg.end());
  if (no)
    cout << "NO";
  else {
    int i;
    for (i = 0; i < n - 1; i++) {
      while (in != edg.size() &&
             !merge(edg[in].second.second, edg[in].second.first, edg[in].first))
        ;
    }
    if (i != n - 1)
      cout << "NO";
    else {
      for (int i = 1; i <= n; i++) {
        clco();
        S.push(make_pair(i, 0));
        while (!S.empty()) {
          if (!Color[S.front().first])
            BFS(i, (S.front()).first, (S.front()).second);
          S.pop();
          if (no) break;
        }
        if (no) break;
      }
      if (no)
        cout << "NO";
      else
        cout << "YES";
    }
  }
}
