#include <bits/stdc++.h>
using namespace std;
int n, dist[2010][2010], best[2010], pred[2010];
bool ales[2010];
vector<pair<int, int> > G[2010];
long long D[2010];
queue<int> Q;
bool bagat[2010];
inline void BFS(int start) {
  int i, x;
  vector<pair<int, int> >::iterator it;
  for (i = 1; i <= n; ++i) {
    D[i] = 3000000000000LL;
    bagat[i] = false;
  }
  D[start] = 0LL;
  Q.push(start);
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    bagat[x] = false;
    for (it = G[x].begin(); it != G[x].end(); ++it) {
      if (D[(*it).first] > D[x] + 1LL * (*it).second) {
        D[(*it).first] = D[x] + 1LL * (*it).second;
        if (!bagat[(*it).first]) {
          bagat[(*it).first] = true;
          Q.push((*it).first);
        }
      }
    }
  }
}
int main() {
  int i, j, ind;
  std::ios_base::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) cin >> dist[i][j];
  for (i = 1; i <= n; ++i) {
    if (dist[i][i] != 0) {
      cout << "NO\n";
      return 0;
    }
    for (j = 1; j < i; ++j) {
      if (dist[i][j] <= 0 || dist[j][i] <= 0 || dist[i][j] != dist[j][i]) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  ales[1] = true;
  for (i = 2; i <= n; ++i) {
    best[i] = dist[1][i];
    pred[i] = 1;
  }
  for (i = 2; i <= n; ++i) {
    ind = -1;
    for (j = 1; j <= n; ++j) {
      if (ales[j]) continue;
      if (ind == -1 || best[j] < best[ind]) ind = j;
    }
    ales[ind] = true;
    G[ind].push_back(make_pair(pred[ind], best[ind]));
    G[pred[ind]].push_back(make_pair(ind, best[ind]));
    for (j = 1; j <= n; ++j)
      if (!ales[j] && best[j] > dist[ind][j]) {
        best[j] = dist[ind][j];
        pred[j] = ind;
      }
  }
  for (i = 1; i <= n; ++i) {
    BFS(i);
    for (j = 1; j <= n; ++j)
      if (1LL * dist[i][j] != D[j]) {
        cout << "NO\n";
        return 0;
      }
  }
  cout << "YES\n";
  return 0;
}
