#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 3;
int a[N][N];
int main() {
  int n, flag = 1;
  scanf("%d", &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]) {
        flag = 0;
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      if (a[i][j] == 0 || a[i][j] != a[j][i]) {
        flag = 0;
        break;
      }
    }
  for (int i = 0; i < n; i++) {
    int r = i == 0 ? 1 : 0;
    for (int j = 0; j < n; j++)
      if (i != j && a[i][j] < a[i][r]) r = j;
    for (int j = 0; j < n; j++) {
      if (abs(a[i][j] - a[r][j]) != a[i][r]) {
        flag = 0;
        break;
      }
    }
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
}
