#include <bits/stdc++.h>
using namespace std;
struct E {
  int from, to, w;
};
int n;
int d[2000][2000];
int dist[2000];
bool used[2000] = {};
vector<pair<int, int> > g[2000];
int V;
bool dfs(int v, int par = -1, int cur = 0) {
  for (pair<int, int> to : g[v])
    if (to.first != par) {
      if (cur + to.second != d[V][to.first]) return false;
      if (!dfs(to.first, v, cur + to.second)) return false;
    }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) {
      scanf("%d", d[i] + j);
    }
  for (int i = 0; i < (int)(n); ++i)
    if (d[i][i] != 0) {
      printf("NO\n");
      return 0;
    }
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j)
      if (i != j && d[i][j] == 0) {
        printf("NO\n");
        return 0;
      }
  for (int i = 0; i < (int)(n); ++i)
    for (int j = i + 1; j < n; ++j)
      if (d[i][j] != d[j][i]) {
        printf("NO\n");
        return 0;
      }
  for (int i = 0; i < (int)(n); ++i) dist[i] = d[0][i];
  used[0] = true;
  for (int i = 1; i < n; ++i) {
    int v = -1;
    for (int j = 0; j < (int)(n); ++j)
      if (!used[j] && (v == -1 || dist[j] < dist[v])) v = j;
    int from = -1;
    for (int j = 0; j < (int)(n); ++j)
      if (used[j] && dist[v] == d[v][j]) {
        from = j;
        break;
      }
    assert(from != -1);
    V = v;
    g[v].push_back(make_pair(from, dist[v]));
    g[from].push_back(make_pair(v, dist[v]));
    if (!dfs(v)) {
      cout << "NO\n";
      return 0;
    }
    for (int i = 0; i < (int)(n); ++i) dist[i] = min(dist[i], d[v][i]);
    used[v] = true;
  }
  cout << "YES\n";
  return 0;
}
