#include <bits/stdc++.h>
using namespace std;
int inf_int = 2e9;
long long inf_ll = 2e18;
const double pi = 3.1415926535898;
template <typename T>
void prin(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << " ";
  }
}
template <typename T>
void prin_new_line(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << "\n";
  }
}
template <typename T>
T sum_vec(vector<T>& a) {
  T s = 0;
  for (int i = 0; i < a.size(); i++) {
    s += a[i];
  }
  return s;
}
template <typename T>
T max(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = max(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = min(ans, a[i]);
  }
  return ans;
}
int min(int a, int b, int c) { return min(a, min(b, c)); }
long long min(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
int max(int a, int b, int c) { return max(a, max(b, c)); }
long long max(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
double s_triangle(double x1, double y1, double x2, double y2, double x3,
                  double y3) {
  return (((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2);
}
vector<pair<int, int> > g[3000];
int parent[3000];
int asdasdasd[3000];
void make_set(int v) {
  parent[v] = v;
  asdasdasd[v] = 1;
}
int d[3000][3000];
int find_parent(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_parent(parent[v]);
}
void union_set(int a, int b) {
  if (asdasdasd[a] < asdasdasd[b]) swap(a, b);
  parent[b] = a;
  if (asdasdasd[b] == asdasdasd[a]) asdasdasd[a]++;
}
void dfs(int v, int p, int st) {
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    int len = g[v][i].second;
    if (to != p) {
      d[st][to] = d[st][v] + len;
      dfs(to, v, st);
    }
  }
}
void solve() {
  int n;
  scanf("%d", &n);
  int a[n][n];
  for (int i = 0; i < n; i++) {
    for (int e = 0; e < n; e++) {
      scanf("%d", &a[i][e]);
    }
  }
  vector<pair<long long, pair<int, int> > > b;
  for (int i = 0; i < n; i++) {
    for (int e = i; e < n; e++) {
      if (a[i][e] == 0 && i != e) {
        cout << "NO";
        return;
      }
      if (a[i][e] != a[e][i]) {
        cout << "NO";
        return;
      }
      b.push_back({a[i][e], {i, e}});
    }
    make_set(i);
    if (a[i][i] != 0) {
      cout << "NO";
      return;
    }
  }
  sort(b.begin(), b.end());
  for (int i = 0; i < b.size(); i++) {
    int len = b[i].first;
    int x = b[i].second.first, y = b[i].second.second;
    int x1, y1;
    x1 = find_parent(x);
    y1 = find_parent(y);
    if (x1 != y1) {
      union_set(x1, y1);
      g[x].push_back({y, len});
      g[y].push_back({x, len});
    }
  }
  for (int i = 0; i < n; i++) {
    dfs(i, i, i);
  }
  for (int i = 0; i < n; i++) {
    for (int e = 0; e < n; e++) {
      if (d[i][e] != a[i][e]) {
        cout << "NO";
        return;
      }
    }
  }
  cout << "YES";
}
int main() {
  if (!1) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int t = 1;
  while (t--) solve();
}
