#include <bits/stdc++.h>
using namespace std;
int n, ne, mat[2010][2010], parent[2010], u, v, a, b, test[2010][2010],
    test11[2010][2010], help[2010][2010];
bool found;
void read(int &n) {
  int flag = 1;
  n = 0;
  char ch = getchar();
  while (ch < '0' && ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = n * 10 + (ch - '0');
    ch = getchar();
  }
  n = n * flag;
}
int find(int i) {
  while (parent[i]) i = parent[i];
  return i;
}
int uni(int i, int j) {
  if (i != j) {
    parent[j] = i;
    return 1;
  }
  return 0;
}
void dfs(int ne, int i, int sum) {
  int temp = sum;
  for (int j = 1; j <= n; ++j) {
    if (test[i][j] > 0) {
      sum = temp + test[i][j];
      test11[ne][j] = test11[j][ne] = sum;
      test[i][j] = test[j][i] = 0;
      dfs(ne, j, sum);
    }
  }
}
int main() {
  found = true;
  multimap<int, pair<int, int> > edge;
  read(n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      read(mat[i][j]);
    }
  }
  if (n == 1 && !mat[1][1]) {
    puts("YES");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (mat[i][i] != 0) {
      found = false;
      printf("NO\n");
      break;
    }
    for (int j = 1; j <= n; ++j) {
      if (j > i && mat[i][j] != mat[j][i]) {
        found = false;
        printf("NO\n");
        break;
      }
      if (mat[i][j] == 0 && i != j) {
        found = false;
        printf("NO\n");
        break;
      }
    }
    if (!found) break;
  }
  if (found) {
    int flag = 1;
    for (int i = 1; i <= n && flag; i++) {
      int minn = 0x3f3f3f3f, k;
      for (int j = 1; j <= n; j++)
        if (i != j && minn > mat[i][j]) minn = mat[i][j], k = j;
      for (int j = 1; j <= n; j++)
        if (i != j && j != k && abs(mat[i][j] - mat[j][k]) != minn) {
          flag = 0;
          break;
        }
    }
    puts(flag == 0 ? "NO" : "YES");
  }
  return 0;
}
