#include <bits/stdc++.h>
const double inf = 1e20;
using namespace std;
int n, fa[2222];
vector<int> G[2222], v;
priority_queue<pair<long long, pair<int, int> > > pir;
long long d[2222][2222], dd[2222];
int sfind(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = sfind(fa[x]);
}
void dfs(int x, int p) {
  for (int i = 0; i < G[x].size(); i++)
    if (G[x][i] != p) dd[G[x][i]] = dd[x] + d[G[x][i]][x], dfs(G[x][i], x);
}
int main() {
  cin >> n;
  int s = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%I64d", &d[i][j]);
      if (i == j && d[i][j]) {
        printf("%c%c", 'N', 'O');
        return 0;
      }
      if (i != j && !d[i][j]) {
        printf("%c%c", 'N', 'O');
        return 0;
      }
      if (i > j && d[i][j] != d[j][i]) {
        printf("%c%c", 'N', 'O');
        return 0;
      }
      if (i > j) pir.push(make_pair(-d[i][j], make_pair(i, j)));
    }
  for (int i = 1; i <= n; i++) fa[i] = i;
  int i = 0, j = 0;
  while (i < n - 1) {
    pair<long long, pair<int, int> > u = pir.top();
    pir.pop();
    int a = sfind(u.second.first), b = sfind(u.second.second);
    if (a != b) {
      G[u.second.first].push_back(u.second.second);
      G[u.second.second].push_back(u.second.first);
      i++;
      fa[a] = b;
    }
    j++;
  }
  for (int i = 1; i <= n; i++) {
    dd[i] = 0;
    dfs(i, 0);
    for (int j = 1; j <= n; j++)
      if (dd[j] != d[i][j]) {
        printf("%c%c", 'N', 'O');
        return 0;
      }
  }
  printf("%c%c%c", 'Y', 'E', 'S');
  return 0;
}
