#include <bits/stdc++.h>
using namespace std;
int const MAX = 2005;
int mp[MAX][MAX];
int main() {
  int n;
  bool flag = true;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &mp[i][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (mp[i][i] || mp[i][j] != mp[j][i] || (i != j && !mp[i][j])) {
        printf("NO\n");
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int u = 1;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (mp[i][j] < mp[i][u]) u = j;
    }
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (abs(mp[i][j] - mp[j][u]) != mp[i][u]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
}
