#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int INF = 0x3f3f3f3f;
int n, d[MAXN][MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &d[i][j]);
  bool flag = true;
  for (int i = 1; flag && i <= n; ++i)
    for (int j = 1; flag && j <= n; ++j)
      flag = (i == j) ? (d[i][j] == 0) : (d[i][j] == d[j][i] && d[i][j] > 0);
  for (int i = 1; flag && i <= n; ++i) {
    int pos, dmin = INF;
    for (int j = 1; j <= n; ++j)
      if (j != i && d[i][j] < dmin) {
        dmin = d[i][j];
        pos = j;
      }
    for (int j = 1; flag && j <= n; ++j)
      if (j != i && j != pos && abs(d[i][j] - d[pos][j]) != dmin) flag = false;
  }
  puts(flag ? "YES" : "NO");
}
