#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-9;
vector<int> p;
vector<vector<long long> > res;
vector<char> used;
vector<vector<pair<int, int> > > g;
void dfs(int pred, int v, long long cost) {
  used[v] = 1;
  if (pred != v) {
    res[pred][v] = cost;
    res[v][pred] = cost;
  }
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first, buf = g[v][i].second;
    if (!used[to]) dfs(pred, to, cost + buf);
  }
}
int get(int v) {
  if (v == p[v])
    return v;
  else
    return p[v] = get(p[v]);
}
void unite(int a, int b) {
  a = get(a);
  b = get(b);
  if (a != b) p[a] = b;
}
int main() {
  int n;
  cin >> n;
  p.resize(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }
  vector<vector<int> > arr(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &arr[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (arr[i][i] != 0) {
      cout << "NO";
      return 0;
    }
  }
  if (n == 1) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (arr[i][j] != arr[j][i]) {
        cout << "NO";
        return 0;
      }
    }
  }
  vector<pair<int, pair<int, int> > > reb;
  reb.reserve(n * n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (arr[i][j]) reb.push_back(make_pair(arr[i][j], make_pair(i, j)));
    }
  }
  g.resize(n);
  sort(reb.begin(), reb.end());
  for (int i = 0; i < reb.size(); i++) {
    int a = reb[i].second.first, b = reb[i].second.second, cost = reb[i].first;
    if (get(a) != get(b)) {
      g[a].push_back(make_pair(b, cost));
      g[b].push_back(make_pair(a, cost));
      unite(a, b);
    }
  }
  for (int i = 0; i < n; i++) {
    if (get(i) != get(0)) {
      cout << "NO";
      return 0;
    }
  }
  res.assign(n, vector<long long>(n, 0));
  for (int i = 0; i < n; i++) {
    used.assign(n, false);
    dfs(i, i, 0);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[i][j] != res[i][j]) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
