#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1000000000000000;
vector<vector<pair<int, long long int> > > graph;
long long int dist[2001][2001];
void dfs(int lol, int v, int predok, long long int distance) {
  dist[lol][v] = distance;
  dist[v][lol] = distance;
  for (int i = 0; i < graph[v].size(); i++)
    if (graph[v][i].first != predok)
      dfs(lol, graph[v][i].first, v, distance + graph[v][i].second);
}
int main() {
  int n, k, ans = 0;
  bool ok = true;
  static long long int g[2001][2001];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%I64d.", &g[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if ((g[i][j] != g[j][i]) || ((i != j) && (g[i][j] == 0))) ok = false;
  for (int i = 0; i < n; i++)
    if (g[i][i] > 0) ok = false;
  vector<bool> used(n);
  vector<long long int> min_e(n, INF), sel_e(n, -1);
  min_e[0] = 0;
  graph.resize(n);
  for (int i = 0; i < n; ++i) {
    int v = -1;
    for (int j = 0; j < n; ++j)
      if (!used[j] && (v == -1 || min_e[j] < min_e[v])) v = j;
    if (min_e[v] == INF) {
      ok = false;
      break;
    }
    used[v] = true;
    if (sel_e[v] != -1) {
      graph[v].push_back(make_pair(sel_e[v], g[v][sel_e[v]]));
      graph[sel_e[v]].push_back(make_pair(v, g[sel_e[v]][v]));
    }
    for (int to = 0; to < n; ++to)
      if (g[v][to] < min_e[to]) {
        min_e[to] = g[v][to];
        sel_e[to] = v;
      }
  }
  for (int i = 0; i < n; i++) dfs(i, i, -1, 0);
  int count = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (dist[i][j] == g[i][j]) count++;
  if (count != n * n) ok = false;
  if (ok)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
