#include <bits/stdc++.h>
using namespace std;
int graph[2005][2005];
int graphf[2005][2005];
int tree[2005], dist[2005];
int pa[2005];
vector<pair<int, int> > graph2[2005];
int n;
int prim() {
  int v0, cost = 0;
  for (int i = 1; i < n; ++i) {
    pa[i] = -1;
    tree[i] = 0;
    dist[i] = graph[0][i];
  }
  pa[0] = 0;
  while (1) {
    int mincost = 0x3f3f3f3f;
    for (int i = 0; i < n; ++i)
      if (pa[i] == -1 && mincost > dist[i]) mincost = dist[v0 = i];
    if (mincost == 0x3f3f3f3f) break;
    pa[v0] = tree[v0];
    cost += mincost;
    for (int i = 0; i < n; ++i)
      if (pa[i] == -1 && dist[i] > graph[v0][i]) {
        dist[i] = graph[v0][i];
        tree[i] = v0;
      }
  }
  return cost;
}
void reconstruct() {
  for (int i = 0; i < n; i++) graph2[i].clear();
  for (int i = 0; i < n; i++) {
    int s = i;
    int t = pa[i];
    graph2[s].push_back(pair<int, int>(t, graph[t][s]));
    graph2[t].push_back(pair<int, int>(s, graph[t][s]));
  }
}
bool visited[2005];
void bfs(int p) {
  memset(visited, false, sizeof(visited));
  queue<int> fila;
  fila.push(p);
  graphf[p][p] = 0;
  visited[p] = true;
  while (!fila.empty()) {
    int v = fila.front();
    fila.pop();
    for (int i = 0; i < graph2[v].size(); i++) {
      int c = graph2[v][i].second;
      int n = graph2[v][i].first;
      if (visited[n] == false) {
        graphf[p][n] = graph[p][v] + c;
        fila.push(n);
        visited[n] = true;
      }
    }
  }
}
bool check() {
  for (int i = 0; i < n; i++)
    if (graph[i][i] != 0) return false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        if (graph[i][j] != graph[j][i]) return false;
        if (graph[i][j] == 0) return false;
      }
    }
  }
  return true;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        scanf("%d", &graph[i][j]);
      }
    }
    prim();
    reconstruct();
    for (int i = 0; i < n; i++) {
      bfs(i);
    }
    bool ok = true;
    ok &= check();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) ok &= graph[i][j] == graphf[i][j];
    }
    printf("%s\n", ok ? "YES" : "NO");
  }
  return 0;
}
