#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int inf = 0x7FFFFFFF;
template <class T>
inline bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool checkmax(T &a, T b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int N = 2005;
int dis[N][N];
int p[N * N];
int *_dis = (int *)dis;
int n;
bool cmp(int a, int b) { return _dis[a] < _dis[b]; }
int ds[N];
vector<pair<int, int> > e[N];
int tdis[N];
void dfs(int u, int f, int d) {
  tdis[u] = d;
  for (int i = 0; i < (int)e[u].size(); i++) {
    int del = e[u][i].first, to = e[u][i].second;
    if (to != f) {
      dfs(to, u, d + del);
    }
  }
}
bool check() {
  for (int i = 0; i < int(n); i++)
    if (dis[i][i] != 0) return false;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(n); j++)
      if (dis[i][j] != dis[j][i]) return false;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(n); j++) p[i * n + j] = i * N + j;
  sort(p, p + n * n, cmp);
  int cnt = 0;
  for (int i = 0; i < int(n); i++) ds[i] = 0;
  for (int i = 0; i < int(n * n); i++) {
    int d = p[i], x = d / N, y = d % N;
    if (x == y) continue;
    if (_dis[d] == 0) return false;
    if (ds[x] != ds[y]) continue;
    int cd = ds[x];
    ds[x] = cnt++;
    ds[y] = cnt++;
    e[x].push_back(make_pair(_dis[d], y));
    e[y].push_back(make_pair(_dis[d], x));
    for (int i = 0; i < n; i++) {
      if (ds[i] == cd) {
        if (dis[i][x] + dis[x][y] == dis[i][y])
          ds[i] = ds[x];
        else if (dis[i][y] + dis[x][y] == dis[i][x])
          ds[i] = ds[y];
        else
          return false;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    dfs(i, -1, 0);
    for (int j = 0; j < n; j++) {
      if (dis[i][j] != tdis[j]) return false;
    }
  }
  return true;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < int(n); i++)
      for (int j = 0; j < int(n); j++) scanf("%d", dis[i] + j);
    if (check())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
