#include <bits/stdc++.h>
using namespace std;
int d[2222][2222];
vector<int> ch[2222];
int par[2222][13 + 1];
int toRoot[2222], lv[2222];
int n;
void exit_no(void) {
  printf("NO");
  exit(0);
}
void init(void) {
  scanf("%d", &n);
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1) scanf("%d", &d[i][j]);
}
void precheck(void) {
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1) {
      if (i == j && d[i][j] != 0) exit_no();
      if (i != j && d[i][j] <= 0) exit_no();
      if (d[i][j] != d[j][i]) exit_no();
    }
}
bool cmp(const int &x, const int &y) { return (d[1][x] < d[1][y]); }
void prepare(void) {
  lv[0] = -1;
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (i != j && d[1][i] + d[i][j] == d[1][j]) ch[i].push_back(j);
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    sort(ch[i].begin(), ch[i].end(), cmp);
}
void dfs(int u) {
  for (__typeof((ch[u]).begin()) it = (ch[u]).begin(); it != (ch[u]).end();
       it++)
    if (par[*it][0] <= 0) {
      par[*it][0] = u;
      toRoot[*it] = toRoot[u] + d[*it][u];
      lv[*it] = lv[u] + 1;
      dfs(*it);
    }
}
void setupLCA(void) {
  dfs(1);
  for (int i = (2), _b = (n); i <= _b; i = i + 1)
    if (par[i][0] <= 0) exit_no();
  for (int j = (1), _b = (13); j <= _b; j = j + 1)
    for (int i = (1), _b = (n); i <= _b; i = i + 1)
      par[i][j] = par[par[i][j - 1]][j - 1];
}
int LCA(int u, int v) {
  if (lv[u] < lv[v]) return (LCA(v, u));
  for (int i = (13), _a = (0); i >= _a; i = i - 1)
    if (lv[par[u][i]] >= lv[v]) u = par[u][i];
  if (u == v) return (u);
  for (int i = (13), _a = (0); i >= _a; i = i - 1)
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return (par[u][0]);
}
int dis(int u, int v) {
  return (toRoot[u] + toRoot[v] - 2 * toRoot[LCA(u, v)]);
}
void finalcheck(void) {
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (dis(i, j) != d[i][j]) exit_no();
  printf("YES");
}
int main(void) {
  init();
  precheck();
  prepare();
  setupLCA();
  finalcheck();
  return 0;
}
