#include <bits/stdc++.h>
using namespace std;
vector<int> rep;
vector<vector<pair<int, long long> > > g;
vector<vector<long long> > dis;
int cr(int a) {
  if (rep[a] == a) return a;
  return rep[a] = cr(rep[a]);
}
bool dfs(int a, int pad, long long acum, int orig) {
  if (dis[a][orig] != acum) return false;
  for (int i = 0; i < g[a].size(); i++) {
    int b = g[a][i].first;
    long long c = g[a][i].second;
    if (b == pad) continue;
    if (not dfs(b, a, acum + c, orig)) return false;
  }
  return true;
}
struct pt {
  int a;
  int b;
  long long c;
};
bool compare(const pt& a, const pt& b) { return a.c < b.c; }
int main() {
  int n;
  cin >> n;
  dis = vector<vector<long long> >(n, vector<long long>(n));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &dis[i][j]);
  for (int i = 0; i < n; i++)
    if (dis[i][i] != 0) {
      cout << "NO" << endl;
      return 0;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++) {
      if (dis[i][j] != dis[j][i]) {
        cout << "NO" << endl;
        return 0;
      }
      if (dis[i][j] == 0) {
        cout << "NO" << endl;
        return 0;
      }
    }
  vector<pt> v(n * (n - 1) / 2);
  int ii = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++) {
      pt p;
      p.a = i;
      p.b = j;
      p.c = dis[i][j];
      v[ii++] = p;
    }
  sort(v.begin(), v.end(), compare);
  rep = vector<int>(n);
  for (int i = 0; i < n; i++) rep[i] = i;
  g = vector<vector<pair<int, long long> > >(n);
  int ncc = n;
  for (int i = 0; i < v.size(); i++) {
    int a = v[i].a;
    int b = v[i].b;
    long long c = v[i].c;
    if (cr(a) != cr(b)) {
      g[a].push_back(pair<int, long long>(b, c));
      g[b].push_back(pair<int, long long>(a, c));
      rep[cr(a)] = cr(b);
      if (--ncc == 0) break;
    }
  }
  bool pos = true;
  for (int i = 0; i < n; i++) {
    if (not dfs(i, -1, 0, i)) {
      pos = false;
      break;
    }
  }
  if (pos)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
