#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
const int INF = 0x3f3f3f3f;
int graph[maxn][maxn];
int prior[maxn];
int visit[maxn];
int dis[maxn];
int f[maxn][maxn];
int n;
bool check() {
  for (int i = 0; i < n; i++) {
    dis[i] = INF;
    if (graph[i][i] != 0) return false;
    for (int j = i + 1; j < n; j++) {
      if (graph[i][j] != graph[j][i] || graph[i][j] == 0) return false;
    }
  }
  memset(visit, 0, sizeof(visit));
  memset(prior, -1, sizeof(prior));
  memset(f, 0, sizeof(f));
  int cent = n;
  dis[0] = 0;
  while (cent--) {
    int min = -1;
    for (int i = 0; i < n; i++) {
      if (!visit[i] && (min == -1 || dis[i] < dis[min])) {
        min = i;
      }
    }
    for (int i = 0; i < n; i++) {
      if (visit[i]) {
        f[i][min] = f[min][i] = f[i][prior[min]] + dis[min];
      }
    }
    visit[min] = true;
    for (int i = 0; i < n; i++) {
      if (dis[i] > graph[min][i]) {
        dis[i] = graph[min][i];
        prior[i] = min;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (f[i][j] != graph[i][j]) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        cin >> graph[i][j];
      }
    if (check())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
