#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007, maxn = 1000000;
int n;
int matriz[2010][2010];
vector<int> adj[2010];
bool visi[2010];
typedef bool (*comp)(pair<int, int>, pair<int, int>);
bool compare(pair<int, int> a, pair<int, int> b) {
  return matriz[a.first][a.second] > matriz[b.first][b.second];
}
bool dfs(int s, int u, int p, bool not_visi);
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &matriz[i][j]);
      if (i == j and matriz[i][j] != 0) {
        printf("NO\n");
        return 0;
      } else if (i != j and matriz[i][j] == 0) {
        printf("NO\n");
        return 0;
      }
      if (j < i and matriz[i][j] != matriz[j][i]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  std::priority_queue<pair<int, int>, std::vector<pair<int, int> >, comp> q(
      compare);
  visi[0] = true;
  for (int i = 1; i < n; i++) {
    q.push(pair<int, int>(0, i));
  }
  int cont = 1;
  while (!q.empty()) {
    pair<int, int> aux = q.top();
    q.pop();
    if (visi[aux.second]) continue;
    visi[aux.second] = true;
    adj[aux.first].push_back(aux.second);
    adj[aux.second].push_back(aux.first);
    if (++cont == n) {
      break;
    }
    for (int i = 0; i < n; i++)
      if (i != aux.second and !visi[i]) {
        q.push(pair<int, int>(aux.second, i));
      }
  }
  memset(visi, false, sizeof(visi));
  bool aux = false;
  for (int i = 0; i < n; i++) {
    if (!dfs(i, i, 0, aux)) {
      printf("NO\n");
      return 0;
    }
    aux = !aux;
  }
  printf("YES\n");
}
bool dfs(int s, int u, int p, bool not_visi) {
  if (visi[u] == !not_visi) return true;
  visi[u] = !not_visi;
  if (matriz[s][u] != p) {
    return false;
  }
  for (int i = 0; i < (int)adj[u].size(); i++) {
    if (!dfs(s, adj[u][i], p + matriz[u][adj[u][i]], not_visi)) {
      return false;
    }
  }
  return true;
}
