#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
void show(long double a, int x, bool endofline, bool space) {
  cout << fixed << setprecision(x) << a;
  if (endofline) cout << endl;
  if (space) cout << ' ';
}
int readInt() {
  bool minus = false;
  int result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus)
    return -result;
  else
    return result;
}
inline void writeInt(long long n) {
  long long N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar('0');
    putchar('\n');
    return;
  }
  while ((rev % 10) == 0) {
    count++;
    rev /= 10;
  }
  rev = 0;
  while (N != 0) {
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) {
    putchar(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar('0');
}
int i, x, z, j, n;
int par[MAXN], matrix[MAXN][MAXN], ar[MAXN][MAXN];
vector<pair<int, int> > v[MAXN];
pair<int, pair<int, int> > pop_back[MAXN * MAXN];
string s;
bool flag[MAXN][MAXN];
void debug() { cout << "DEBUGGING\n"; }
int getroot(long long a) {
  if (par[a] == a) return a;
  par[a] = getroot(par[a]);
  return par[a];
}
void dfs(long long nod, long long org, long long dis) {
  for (long long jj = 0; jj < v[nod].size(); jj++) {
    if (!flag[v[nod][jj].first][org]) {
      flag[v[nod][jj].first][org] = true;
      matrix[org][v[nod][jj].first] = dis + v[nod][jj].second;
      dfs(v[nod][jj].first, org, matrix[org][v[nod][jj].first]);
    }
  }
}
void MST() {
  sort(pop_back, pop_back + x);
  for (i = 0; i < n; i++) par[i] = i;
  for (i = 0; i < x; i++) {
    pair<int, pair<int, int> > p = pop_back[i];
    long long u = p.second.first, vv = p.second.second;
    long long paru = getroot(u), parv = getroot(vv);
    if (paru != parv) {
      par[parv] = paru;
      v[u].push_back(make_pair(vv, p.first));
      v[vv].push_back(make_pair(u, p.first));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      ar[i][j] = readInt();
      pop_back[x] = make_pair(ar[i][j], make_pair(i, j));
      x++;
    }
  MST();
  for (i = 0; i < n; i++) {
    flag[i][i] = true;
    dfs(i, i, 0);
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      if (ar[i][j] != matrix[i][j]) return cout << "NO", 0;
      if (i != j && ar[i][j] == 0) return cout << "NO", 0;
    }
  cout << "YES";
}
