#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
  point() {}
  point(int a, int b) { x = a, y = b; }
};
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T power(T n, T p) {
  T res = 1;
  for (int i = 0; i < p; i++) res *= n;
  return res;
}
template <class T>
double getdist(T a, T b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
template <class T>
T extract(string s, T ret) {
  stringstream ss(s);
  ss >> ret;
  return ret;
}
template <class T>
string tostring(T n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
template <class T>
inline T Mod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
void print_all(T v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
};
template <class T>
void print_all(T &v, int len) {
  for (int i = 0; i < len; i++) cout << v[i] << ' ';
}
template <class T>
void print_pair(T v, int len) {
  for (int i = 0; i < len; i++)
    cout << v[i].first << ' ' << v[i].second << endl;
}
long long bigmod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return R;
}
struct edge {
  int u, v, w;
  edge() {}
  edge(int _u, int _v, int _w) {
    u = _u;
    v = _v;
    w = _w;
  }
  bool operator<(const edge &p) const { return w < p.w; }
};
vector<edge> edgeList;
vector<pair<int, int> > adj[2010];
int par[2010], arr[2010][2010], dist[2010];
int find_set(int node) {
  if (par[node] == node) return node;
  return par[node] = find_set(par[node]);
}
void mst(int n) {
  int cnt = n - 1, i;
  sort(edgeList.begin(), edgeList.end());
  for (i = 1; i <= n; i++) par[i] = i;
  for (i = 0; i < (int)(edgeList.size()) && cnt; i++) {
    int u = find_set(edgeList[i].u);
    int v = find_set(edgeList[i].v);
    if (u != v) {
      par[u] = v;
      adj[edgeList[i].u].push_back(make_pair(edgeList[i].v, edgeList[i].w));
      adj[edgeList[i].v].push_back(make_pair(edgeList[i].u, edgeList[i].w));
      cnt--;
    }
  }
}
void dfs(int node, int d) {
  if (dist[node] != -1) return;
  dist[node] = d;
  for (int i = 0; i < (int)(adj[node].size()); i++)
    dfs(adj[node][i].first, d + adj[node][i].second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      cin >> arr[i][j];
      if (arr[i][j]) edgeList.push_back(edge(i, j, arr[i][j]));
    }
  mst(n);
  for (i = 1; i <= n; i++) {
    memset(dist, -1, sizeof dist);
    dfs(i, 0);
    for (j = 1; j <= n; j++) {
      if (dist[j] != arr[i][j]) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
