#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 0x7fffffff;
int n, d[2005][2005];
bool ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  ans = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) cin >> d[i][j];
  for (int i = 1; i <= n; ++i)
    if (d[i][i]) ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (i != j && (d[i][j] != d[j][i] || d[i][j] == 0)) ans = 0;
  if (n > 1)
    for (int i = 1; i <= n; ++i) {
      int dis = MAXINT, pos = MAXINT;
      for (int j = 1; j <= n; ++j)
        if (j != i && d[i][j] < dis) dis = d[i][j], pos = j;
      for (int j = 1; j <= n; ++j)
        if (j != pos)
          if (abs(d[i][j] - d[j][pos]) != dis) ans = 0;
    }
  printf("%s", ans ? "YES" : "NO");
}
