#include <bits/stdc++.h>
using namespace std;
struct edge {
  bool visit[101];
  int parent[101] = {0};
  int parentx;
  int val;
  void makeset(int n) {
    for (int i = 0; i <= n; i++) parent[i] = i;
  }
  void MergeSet(int a, int b) {
    int pa = find(a);
    int pb = find(b);
    if (pa != pb) {
      parent[pa] = pb;
    }
  }
  int find(int a) {
    if (a == parent[a] || parent[a] == 0) {
      return a;
    }
    return parent[a] = find(parent[a]);
  }
};
long long int a[2001][2001] = {0};
int you[105] = {0};
edge v[101];
int b = 0;
bool h[105] = {false};
int main() {
  int m, n, c, d, e;
  long long int res = 0, min;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
      if ((i == j && a[i][j] != 0)) {
        printf("NO");
        return 0;
      } else if (i != j && a[i][j] == 0) {
        printf("NO");
        return 0;
      } else if (j < i && a[i][j] != a[j][i]) {
        printf("NO");
        return 0;
      }
      if (i != j && a[i][b] > a[i][j]) {
        b = j;
      }
    }
  }
  for (int u = 0; u < n; u++) {
    b = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[u][j];
      if (u != j && a[u][b] > a[u][j]) {
        b = j;
      }
    }
    for (int w = 0; w < n; w++)
      if (abs(a[u][w] - a[b][w]) != a[u][b]) {
        printf("NO");
        return 0;
      }
  }
  printf("YES");
  return 0;
}
