#include <bits/stdc++.h>
using namespace std;
int n;
int a[2005][2005];
bool mark;
int v[2005];
void dfs(int x, int y, int t) {
  if (mark) return;
  for (int i = 1; i <= n; ++i) {
    if (a[i][x] == a[i][y] + a[x][y]) {
      if (v[i] == t) v[i] = y;
    } else if (a[i][x] + a[x][y] == a[i][y]) {
      if (v[i] == t) v[i] = x;
    } else {
      mark = true;
      return;
    }
  }
  int minn = 2e9, k = -1;
  for (int i = 1; i <= n; ++i) {
    if (v[i] == x && i != x && a[x][i] < minn) minn = a[x][i], k = i;
  }
  if (k != -1) dfs(x, k, x);
  minn = 2e9, k = -1;
  for (int i = 1; i <= n; ++i) {
    if (v[i] == y && i != y && a[y][i] < minn) minn = a[y][i], k = i;
  }
  if (k != -1) dfs(y, k, y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  int minn = 2e9, u, v;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (a[i][j] != a[j][i]) {
        mark = true;
        break;
      }
      if (i != j && a[i][j] < 1) {
        mark = true;
        break;
      }
      if (i != j && a[i][j] < minn) minn = a[i][j], u = i, v = j;
    }
    if (a[i][i] != 0) mark = true;
    if (mark) break;
  }
  if (n == 1) {
    if (a[1][1] == 0)
      printf("YES\n");
    else
      printf("NO\n");
    return 0;
  }
  dfs(u, v, 0);
  if (mark)
    printf("NO\n");
  else
    printf("YES\n");
}
