#include <bits/stdc++.h>
using namespace std;
int a1[2000][2000];
int main() {
  int n, a;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      scanf("%d", a1[i] + j);
      if ((i == j) == (bool)a1[i][j] || i > j && a1[i][j] != a1[j][i]) {
        puts("NO");
        return 0;
      }
    }
  for (int i = 0; i < n; ++i) {
    a = !i;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (a1[i][j] < a1[i][a]) a = j;
    }
    for (int j = 0; j < n; ++j) {
      if (i == j || a == j) continue;
      if (abs(a1[i][j] - a1[j][a]) != a1[i][a]) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
}
