#include <bits/stdc++.h>
using namespace std;
int n, par[2333], cnt;
vector<int> g[2333];
pair<int, pair<int, int> > dist[2333333];
int d[2333][2333], a[2333][2333];
bool v[2333];
inline int find(int i) { return par[i] == i ? i : par[i] = find(par[i]); }
void dfs(int fat, int u, int dd) {
  v[u] = 1;
  a[fat][u] = dd;
  for (int i = 0; i < g[u].size(); i++)
    if (!v[g[u][i]]) dfs(fat, g[u][i], dd + a[u][g[u][i]]);
}
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &d[i][j]);
}
void slove() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (d[i][j] != d[j][i] || !d[i][j]) {
        puts("NO");
        return;
      }
      dist[cnt++] = make_pair(d[i][j], make_pair(i, j));
    }
    par[i] = i;
    if (d[i][i]) {
      puts("NO");
      return;
    }
  }
  sort(dist, dist + cnt);
  for (int i = 0; i < cnt; i++) {
    int x = dist[i].second.first;
    int y = dist[i].second.second;
    int px = find(x);
    int py = find(y);
    if (px != py) {
      par[px] = py;
      a[x][y] = a[y][x] = dist[i].first;
      g[x].push_back(y);
      g[y].push_back(x);
    }
  }
  for (int i = 0; i < n; i++) {
    memset(v, 0, sizeof(v));
    dfs(i, i, 0);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] != d[i][j]) {
        puts("NO");
        return;
      }
  puts("YES");
  return;
}
int main() {
  init();
  slove();
  return 0;
}
