#include <bits/stdc++.h>
using namespace std;
int matrix[2000][2000];
vector<int> adj[2000];
int vis[2000];
bool flag;
int source, ID;
void dfs(int ind, int cost, int parent) {
  if (!flag) return;
  if (vis[ind] == ID) {
    flag = 0;
    return;
  }
  vis[ind] = ID;
  if (matrix[source][ind] != cost) {
    flag = 0;
    return;
  }
  for (int i = 0; i < (int)adj[ind].size(); i++) {
    if (vis[adj[ind][i]] != ID)
      dfs(adj[ind][i], cost + matrix[ind][adj[ind][i]], ind);
  }
}
struct node {
  int u, v, cost;
};
bool operator<(const node& a, const node& b) { return a.cost < b.cost; }
vector<node> Q;
int rnk[2000], id[2000];
void make_set(int n) {
  for (int i = 0; i < n; i++) {
    rnk[i] = 1;
    id[i] = i;
  }
  return;
}
int getRoot(int i) {
  if (id[i] == i) return i;
  return id[i] = getRoot(id[i]);
}
void join(int i1, int i2) {
  int root1 = getRoot(i1), root2 = getRoot(i2);
  if (rnk[root1] == rnk[root2]) rnk[root1]++;
  if (rnk[root1] < rnk[root2]) swap(root1, root2);
  id[root2] = root1;
  return;
}
int main() {
  int n;
  node cur, temp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &matrix[i][j]);
      if (i == j) continue;
      temp.u = i;
      temp.v = j;
      temp.cost = matrix[i][j];
      Q.push_back(temp);
    }
  sort(Q.begin(), Q.end());
  if (n == 1) {
    if (matrix[0][0] == 0)
      printf("YES\n");
    else
      printf("NO\n");
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (matrix[i][j] != matrix[j][i] || matrix[i][i] ||
          (i != j && matrix[i][j] == 0)) {
        printf("NO\n");
        return 0;
      }
    }
  make_set(n);
  for (int i = 0; i < Q.size(); i++) {
    cur = Q[i];
    int root1 = getRoot(cur.u), root2 = getRoot(cur.v);
    if (root1 != root2) {
      join(cur.u, cur.v);
      adj[cur.u].push_back(cur.v);
      adj[cur.v].push_back(cur.u);
    }
  }
  for (int i = 0; i < n; i++) {
    ID++;
    source = i;
    flag = 1;
    dfs(i, 0, -1);
    if (!flag) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
