#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 2222;
void bad() {
  puts("NO");
  exit(0);
}
int n;
int d[N][N];
long long dist[N][N];
vector<int> g[N];
bool used[N];
void dfs(int root, int u, int par) {
  used[u] = 1;
  for (__typeof((g[u]).begin()) it = (g[u]).begin(); it != (g[u]).end(); it++) {
    int v = *it;
    if (v != par) {
      if (used[v]) {
        bad();
      }
      dist[root][v] = dist[root][u] + d[u][v];
      dfs(root, v, u);
    }
  }
}
int p[N];
void init_set() {
  for (int i = 0; i < N; i++) p[i] = i;
}
int get_set(int x) {
  if (x == p[x]) return x;
  return p[x] = get_set(p[x]);
}
bool merge(int u, int v) {
  u = get_set(u);
  v = get_set(v);
  if (u != v) {
    if (rand() & 1) swap(u, v);
    p[u] = v;
    return 1;
  }
  return 0;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return d[a.first][a.second] < d[b.first][b.second];
}
vector<pair<int, int> > e;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      d[i][j] = read();
      if (i != j) {
        if (d[i][j] == 0) bad();
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (d[i][j] != d[j][i]) {
        bad();
      }
    }
    if (d[i][i] != 0) bad();
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      e.push_back(make_pair(i, j));
    }
  }
  sort((e).begin(), (e).end(), cmp);
  init_set();
  for (__typeof((e).begin()) it = (e).begin(); it != (e).end(); it++) {
    int u = it->first;
    int v = it->second;
    if (merge(u, v)) {
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(used, 0, sizeof used);
    dfs(i, i, 0);
    for (int i = 1; i <= n; i++) {
      if (!used[i]) {
        bad();
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (dist[i][j] != d[i][j]) {
        bad();
      }
    }
  }
  puts("YES");
  return 0;
}
