#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long po(long long a, long long b) {
  if (b == 0) return 1 % mod;
  long long y = po(a, b / 2);
  y = y * y % mod;
  if (b % 2 == 1) y = y * a % mod;
  return y;
}
long long inv(long long i) { return po(i, mod - 2); }
struct trie {
  long long cnt;
  trie* ch[2];
  trie() : cnt(0ll) {
    ch[0] = NULL;
    ch[1] = NULL;
  }
};
int d[2005][2005], n;
void solve() {
  cin >> n;
  for (long long i = (long long)0; i != (long long)n; i = i + 1) {
    for (long long j = (long long)0; j != (long long)n; j = j + 1)
      cin >> d[i][j];
    ;
  }
  bool fo = 0;
  for (long long i = (long long)0; i != (long long)n; i = i + 1) {
    if (d[i][i]) fo = 1;
  }
  for (long long i = (long long)0; i != (long long)n; i = i + 1) {
    for (long long j = (long long)i + 1; j != (long long)n; j = j + 1) {
      if (d[i][j] != d[j][i] || d[i][j] == 0) fo = 1;
    }
  }
  if (n == 1) {
    if (fo)
      cout << "NO" << '\n';
    else
      cout << "YES" << '\n';
    return;
  }
  for (long long i = (long long)0; i != (long long)n; i = i + 1) {
    d[i][n] = int(1e9) + 7;
  }
  for (long long i = (long long)0; i != (long long)n; i = i + 1) {
    int r = n;
    for (long long j = (long long)0; j != (long long)n; j = j + 1) {
      if (d[i][j] < d[i][r] && i != j) r = j;
    }
    for (long long j = (long long)0; j != (long long)n; j = j + 1) {
      if (abs(d[i][j] - d[r][j]) != d[i][r]) fo = 1;
    }
  }
  if (fo)
    cout << "NO" << '\n';
  else
    cout << "YES" << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
