#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
bool u[N];
const int INF = 1e9 + 9;
int d[N][N], nd[N][N];
vector<vector<int> > v;
int ST;
void dfs(int st, int depth = 0) {
  u[st] = true;
  nd[ST][st] = depth;
  for (int j = 0; j < v[st].size(); ++j) {
    int to = v[st][j];
    if (!u[to]) dfs(to, depth + d[st][to]);
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  scanf("%d", &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] == 0) {
      for (int j = i + 1; j < n; ++j)
        if (d[i][j] != d[j][i] || d[i][j] == 0) {
          printf("NO");
          return 0;
        }
    } else {
      printf("NO");
      return 0;
    }
  }
  vector<int> dist(n, INF), fr(n, -1);
  v.resize(n);
  dist[0] = 0;
  for (int i = 0; i < n; ++i) {
    int st = -1;
    long long cur = INF;
    for (int j = 0; j < n; ++j)
      if (!u[j] && (st == -1 || dist[j] < dist[st])) st = j;
    u[st] = true;
    if (fr[st] != -1) {
      v[fr[st]].push_back(st);
      v[st].push_back(fr[st]);
    }
    for (int j = 0; j < n; ++j)
      if (dist[j] > d[st][j]) {
        dist[j] = d[st][j];
        fr[j] = st;
      }
  }
  for (int i = 0; i < n; ++i) u[i] = false;
  for (int i = 0; i < n; ++i) {
    ST = i;
    dfs(i);
    for (int j = 0; j < n; ++j)
      if (!u[j] || nd[ST][j] != d[ST][j]) {
        printf("NO");
        return 0;
      } else
        u[j] = false;
  }
  printf("YES");
  return 0;
}
