#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000;
int n;
int a[maxn + 5][maxn + 5];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++)
    if (a[i][i]) {
      printf("NO\n");
      return 0;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++)
      if (a[i][j] != a[j][i]) {
        printf("NO\n");
        return 0;
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j && !a[i][j]) {
        printf("NO\n");
        return 0;
      }
  for (int i = 1; i <= n; i++) {
    int minp = 1;
    for (int j = 1; j <= n; j++)
      if (i != j && a[i][j] < a[i][minp]) minp = j;
    for (int j = 1; j <= n; j++)
      if (((a[i][j] - a[minp][j]) < (0)
               ? -(a[i][j] - a[minp][j])
               : (a[i][j] - a[minp][j])) != a[i][minp]) {
        printf("NO\n");
        return 0;
      }
  }
  printf("YES\n");
  return 0;
}
