#include <bits/stdc++.h>
using namespace std;
int n;
int a[2005][2005];
int main() {
  scanf("%d", &n);
  int flag = 1;
  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++)
    for (int j = 1; j <= n; j++)
      if ((j == i && a[i][j] != 0) || (j != i && a[i][j] == 0) ||
          a[i][j] != a[j][i]) {
        flag = 0;
        break;
      }
  if (!flag) {
    puts("NO");
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    int pre = 1;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (a[pre][i] > a[j][i]) pre = j;
    }
    for (int j = 1; j <= n; j++) {
      if (i == j || j == pre) continue;
      if (abs(a[pre][j] - a[i][j]) != a[i][pre]) flag = 0;
    }
    if (!flag) break;
  }
  if (flag)
    puts("YES");
  else
    puts("NO");
}
