#include <bits/stdc++.h>
using namespace std;
int d[2123][2123], par[2123];
long long int dp[2123];
priority_queue<pair<int, int> > pq;
bool vis[2123] = {false};
int in[2123], out[2123], ti;
vector<int> child[2123];
void dfs(int u) {
  ti++;
  in[u] = ti;
  for (int i = child[u].size() - 1; i >= 0; i--) {
    dfs(child[u][i]);
  }
  out[u] = ti;
}
int main() {
  int i, j, n;
  int u, v;
  long long int w;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &d[i][j]);
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i == j) {
        if (d[i][j] != 0) {
          cout << "NO" << endl;
          return 0;
        }
      } else {
        if (d[i][j] == 0) {
          cout << "NO" << endl;
          return 0;
        }
      }
      if (d[i][j] != d[j][i]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  for (i = 0; i < n; i++) {
    dp[i] = 1000000000;
    dp[i] *= 1000000000;
  }
  dp[0] = 0;
  pq.push(make_pair(0, 0));
  par[0] = -1;
  while (!pq.empty()) {
    u = pq.top().second;
    pq.pop();
    if (vis[u] == true) {
      continue;
    }
    vis[u] = true;
    for (v = 0; v < n; v++) {
      if (vis[v] == false) {
        if (d[u][v] < dp[v]) {
          par[v] = u;
          dp[v] = d[u][v];
          pq.push(make_pair(-dp[v], v));
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    u = par[i];
    v = i;
    w = 0;
    while (u != -1) {
      w += d[u][v];
      if (w != d[u][i]) {
        cout << "NO" << endl;
        return 0;
      }
      v = u;
      u = par[u];
    }
  }
  for (i = 1; i < n; i++) {
    child[par[i]].push_back(i);
  }
  ti = 0;
  dfs(0);
  for (i = 1; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (in[j] >= in[i] && out[j] <= out[i]) {
        continue;
      }
      if (d[i][j] != d[i][par[i]] + d[par[i]][j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
