#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int mat[2002][2002], pset[2002];
int find(int i) { return (pset[i] == i) ? i : (pset[i] = find(pset[i])); }
void join(int i, int j) { pset[find(i)] = find(pset[j]); }
struct X {
  long long int v, c;
};
X no(long long int v, long long int c) {
  X novo;
  novo.v = v;
  novo.c = c;
  return novo;
}
vector<X> graph[100001];
long long int pai[100001][17], distancia[100001][17], prof[100001];
int n;
void monta(long long int v, long long int p, long long int pro,
           long long int d) {
  prof[v] = pro;
  pai[v][0] = p;
  distancia[v][0] = d;
  for (int i = 1; i < 17; i++) {
    pai[v][i] = pai[pai[v][i - 1]][i - 1];
    distancia[v][i] = distancia[v][i - 1] + distancia[pai[v][i - 1]][i - 1];
  }
  for (int i = 0; i < graph[v].size(); ++i) {
    if (graph[v][i].v == p) continue;
    monta(graph[v][i].v, v, pro + 1, graph[v][i].c);
  }
}
void pre_process() {
  prof[0] = 0;
  for (int i = 0; i < 17; ++i) {
    pai[0][i] = 0;
    distancia[0][i] = 0;
  }
  for (int i = 0; i < graph[0].size(); ++i)
    monta(graph[0][i].v, 0, 1, graph[0][i].c);
}
pair<int, long long int> LCA(int a, int b) {
  long long int d = 0;
  int pa = a, push_back = b;
  if (prof[push_back] > prof[pa]) swap(pa, push_back);
  while (prof[pa] > prof[push_back]) {
    int j = 0;
    for (int i = 0; i < 17; ++i) {
      if (prof[pai[pa][i]] < prof[push_back]) break;
      j = i;
    }
    d += distancia[pa][j];
    pa = pai[pa][j];
  }
  while (pa != push_back) {
    int j = 0;
    for (int i = 0; i < 17; ++i) {
      if (pai[pa][i] == pai[push_back][i]) break;
      j = i;
    }
    d += distancia[pa][j];
    d += distancia[push_back][j];
    pa = pai[pa][j];
    push_back = pai[push_back][j];
  }
  return make_pair(pa, d);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) pset[i] = i;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) cin >> mat[i][j];
  priority_queue<pair<int, pair<int, int> > > q;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (mat[i][j] != mat[j][i] || ((i == j) && mat[i][j] != 0)) {
        cout << "NO\n";
        return 0;
      }
      if (mat[i][j] != 0) q.push(make_pair(-mat[i][j], make_pair(i, j)));
    }
  }
  while (!q.empty()) {
    pair<int, pair<int, int> > foo = q.top();
    q.pop();
    int w = foo.first * -1;
    int u = foo.second.first;
    int v = foo.second.second;
    if (find(u) != find(v)) {
      join(u, v);
      graph[u].push_back(no(v, w));
      graph[v].push_back(no(u, w));
    }
  }
  set<int> s;
  for (int i = 0; i < n; ++i) {
    s.insert(find(i));
  }
  if (s.size() != 1) {
    cout << "NO\n";
    return 0;
  }
  pre_process();
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      pair<long long, long long> resp = LCA(i, j);
      if (resp.second != mat[i][j]) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
