#include <bits/stdc++.h>
using namespace std;
int D[2222][2222];
int D1[2222][2222];
bool vis[2222];
int n, N;
bool valid = true;
int T[2222], P[2222][20];
int L[2222];
long long int dist[2222];
vector<int> childs[2222];
vector<pair<int, int> > v[2222];
void dfs(int x, int dep) {
  L[x] = dep;
  for (int i = 0; i < n; i++) {
    int xx = v[x][i].second;
    if (!vis[xx] && D[0][xx] == D[x][xx] + D[0][x]) {
      vis[xx] = true;
      T[xx] = x;
      childs[x].push_back(xx);
      dfs(xx, dep + 1);
    }
  }
}
int solve(int x, int y) {
  if (x == y) return 0;
  if (D1[x][y]) return D1[x][y];
  if (L[x] >= L[y]) {
    return D1[x][y] = D[x][T[x]] + solve(T[x], y);
  } else {
    return D1[x][y] = D[y][T[y]] + solve(x, T[y]);
  }
}
int main() {
  scanf("%d", &n);
  N = n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &D[i][j]);
  for (int i = 0; i < n; i++)
    if (D[i][i]) {
      printf("NO\n");
      return 0;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (D[i][j] != D[j][i] || !D[i][j]) {
        printf("NO\n");
        return 0;
      }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) v[i].push_back(make_pair(D[i][j], j));
    sort(v[i].begin(), v[i].end());
  }
  vis[0] = true;
  T[0] = -1;
  dfs(0, 0);
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      printf("NO\n");
      return 0;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j && !D1[i][j]) {
        int x = solve(i, j);
        D1[i][j] = D1[j][i] = solve(i, j);
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (D[i][j] != D1[i][j]) {
        printf("NO\n");
        return 0;
      }
  printf("YES\n");
  return 0;
}
