#include <bits/stdc++.h>
using namespace std;
struct node {
  node* rep;
  vector<pair<int, node*> > edges;
  bool visited;
  int dist;
  node() : visited(false) {}
} nodes[2000];
node* parent(node* n) { return n->rep == n ? n : (n->rep = parent(n->rep)); }
void dfs(node& n) {
  if (n.visited) return;
  n.visited = true;
  for (auto& e : n.edges) {
    if (e.second->visited) continue;
    e.second->dist = n.dist + e.first;
    dfs(*e.second);
  }
}
int N;
int D[2000][2000];
int main() {
  scanf("%d", &(N));
  for (int i = (0); i < (N); i++)
    for (int j = (0); j < (N); j++) scanf("%d", &(D[i][j]));
  for (int i = (0); i < (N); i++)
    for (int j = (0); j < (N); j++) {
      if ((i == j && D[i][j] != 0) || (D[i][j] != D[j][i]) ||
          (i != j && D[i][j] == 0)) {
        printf("NO\n");
        return 0;
      }
    }
  for (int i = (0); i < (N); i++) nodes[i].rep = nodes + i;
  vector<pair<int, pair<int, int> > > V;
  for (int i = (0); i < (N); i++)
    for (int j = (0); j < (N); j++) {
      if (i < j) {
        V.push_back(make_pair(D[i][j], make_pair(i, j)));
      }
    }
  sort(V.begin(), V.end());
  for (int i = (0); i < (V.size()); i++) {
    node* a = nodes + V[i].second.first;
    node* b = nodes + V[i].second.second;
    if (parent(a) != parent(b)) {
      a->edges.push_back(make_pair(V[i].first, b));
      b->edges.push_back(make_pair(V[i].first, a));
      parent(b)->rep = a;
    }
  }
  for (int i = (0); i < (N); i++) {
    for (int j = (0); j < (N); j++) nodes[j].visited = false;
    nodes[i].dist = 0;
    dfs(nodes[i]);
    for (int j = (0); j < (N); j++) {
      if (nodes[j].dist != D[i][j]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
}
