#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void solve() {
  long long n;
  cin >> n;
  long long a[n][n];
  long long closest[n];
  for (long long i = 0; i < n; i += 1) {
    long long mn = INT64_MAX, ind = -1;
    for (long long j = 0; j < n; j += 1) {
      cin >> a[i][j];
      if ((i == j && a[i][j] != 0) || (i != j && a[i][j] == 0)) {
        cout << "NO\n";
        return;
      }
      if (a[i][j] != 0) {
        if (mn > a[i][j]) {
          mn = a[i][j];
          ind = j;
        }
      }
    }
    closest[i] = ind;
  }
  for (long long i = 0; i < n; i += 1) {
    for (long long j = 0; j < n; j += 1) {
      if (!(a[i][j] == a[i][closest[i]] + a[closest[i]][j] ||
            a[closest[i]][j] == a[i][j] + a[i][closest[i]])) {
        cout << "NO\n";
        return;
      }
    }
  }
  cout << "YES\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tin = 1;
  while (tin--) {
    solve();
  }
  return 0;
}
