#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& in, vector<T>& v) {
  for (int i = (0); i < int(v.size()); ++i) in >> v[i];
  return in;
}
template <typename A, typename B>
istream& operator>>(istream& in, pair<A, B>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
  if (v.size()) out << v[0];
  for (int i = (1); i < int(v.size()); ++i) out << ' ' << v[i];
  return out;
}
template <typename A, typename B>
ostream& operator<<(ostream& out, pair<A, B>& p) {
  out << p.first << ' ' << p.second;
  return out;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int> > dist(n, vector<int>(n));
  vector<vector<pair<int, int> > > adj(n);
  cin >> dist;
  for (int i = (0); i < int(n); ++i) {
    if (dist[i][i]) goto fail;
    for (int j = (0); j < int(i); ++j)
      if (dist[i][j] != dist[j][i] || !dist[i][j]) goto fail;
  }
  {
    vector<bool> done(n, false);
    vector<pair<int, int> > prev(n, make_pair(2000000000, -1));
    prev[0] = make_pair(0, 0);
    for (int i = (0); i < int(n); ++i) {
      auto cur = min_element((prev).begin(), (prev).end());
      int v = cur - prev.begin();
      if (v) {
        adj[v].push_back(*cur);
        adj[cur->second].push_back(make_pair(cur->first, v));
      }
      prev[v].first = 2000000000;
      done[v] = true;
      for (int j = (0); j < int(n); ++j) {
        if (!done[j]) {
          prev[j] = min(prev[j], make_pair(dist[v][j], v));
        }
      }
    }
    for (int i = (0); i < int(n); ++i) {
      vector<int> now(n, -1);
      now[i] = 0;
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int cur = q.front();
        q.pop();
        for (__typeof((adj[cur]).begin()) it = (adj[cur]).begin();
             it != (adj[cur]).end(); ++it) {
          if (now[it->second] == -1) {
            now[it->second] = now[cur] + it->first;
            q.push(it->second);
          }
        }
      }
      for (int j = (0); j < int(n); ++j)
        if (dist[i][j] != now[j]) goto fail;
    }
    cout << "YES" << endl;
    return;
  }
fail:;
  cout << "NO" << endl;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(false);
  solve();
}
