#include <bits/stdc++.h>
using namespace std;
int n, q, m;
const int maxn = 2000 + 2;
int a[maxn][maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if ((i != j && !a[i][j]) || (i == j && a[i][j]) || (a[i][j] != a[j][i]))
        m = 2;
  for (int i = 1; i <= n; i++) {
    q = 1;
    for (int j = 1; j <= n; j++)
      if (i != j && a[i][j] < a[i][q]) q = j;
    for (int s = 1; s <= n; s++)
      if (abs(a[i][s] - a[q][s]) != a[i][q]) m = 2;
  }
  if (m != 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
