#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
int O[2012][2012];
pair<int, pair<int, int> > E[2012 * 2012];
vector<pair<int, int> > A[2012];
int P[2012];
long long OO[2012][2012];
int root(int i) {
  if (i == P[i])
    return i;
  else
    return P[i] = root(P[i]);
}
void dfs(int x, int i, int p = -1, long long a = 0) {
  OO[x][i] = a;
  int j, k;
  for (k = (0); k < (A[i].size()); ++k) {
    j = A[i][k].first;
    if (j == p) continue;
    dfs(x, j, i, a + A[i][k].second);
  }
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    for (i = (0); i < (n); ++i)
      for (j = (0); j < (n); ++j)
        scanf(
            "%"
            "d",
            &(O[i][j]));
    m = 0;
    for (i = (0); i < (n); ++i) {
      for (j = (0); j < (n); ++j) {
        if (i == j && O[i][j]) break;
        if (i != j && !O[i][j]) break;
        if (O[i][j] != O[j][i]) break;
      }
      if (j < n) break;
    }
    if (i < n)
      printf(
          "%"
          "s",
          ("NO")),
          printf("\n"), firstout = 1;
    else {
      for (i = (0); i < (n); ++i)
        for (j = (i + 1); j < (n); ++j)
          E[m++] = make_pair(O[i][j], make_pair(i, j));
      sort(E, E + m);
      for (i = (0); i < (n); ++i) P[i] = i;
      for (i = (0); i < (n); ++i) A[i].clear();
      for (k = (0); k < (m); ++k) {
        a = E[k].first;
        i = E[k].second.first;
        j = E[k].second.second;
        int ii = root(i);
        int jj = root(j);
        if (ii == jj) continue;
        P[ii] = P[jj];
        A[i].push_back(make_pair(j, a));
        A[j].push_back(make_pair(i, a));
      }
      for (i = (0); i < (n); ++i) dfs(i, i);
      for (i = (0); i < (n); ++i) {
        for (j = (0); j < (n); ++j)
          if (O[i][j] != OO[i][j]) break;
        if (j < n) break;
      }
      printf(
          "%"
          "s",
          (i < n ? "NO" : "YES"));
      printf("\n"), firstout = 1;
    }
  }
  return 0;
}
