#include <bits/stdc++.h>
using namespace std;
int bin_search(int *a, int s, int len) {
  int l = 0, h = len - 1, mid;
  while (l <= h) {
    mid = (l + h) / 2;
    if (a[mid] < s)
      l = mid + 1;
    else if (a[mid] > s)
      h = mid - 1;
    else
      return 1;
  }
  return 0;
}
int main() {
  int n;
  ios ::sync_with_stdio(false);
  cin >> n;
  int dist[n + 1][n + 1], a[n];
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) cin >> dist[i][j];
  }
  for (int i = 1; i < n + 1; i++) a[i - 1] = dist[1][i];
  sort(a, a + n);
  for (int i = 1; i < n + 1; i++) {
    for (int j = i; j < n + 1; j++) {
      if (i == j && dist[i][j] != 0) {
        cout << "NO" << endl;
        return 0;
      }
      if (i != j) {
        if (dist[i][j] != dist[j][i] || dist[i][j] == 0) {
          cout << "NO" << endl;
          return 0;
        }
        int d = dist[1][j] + dist[1][i] - dist[i][j];
        if (d < 0 || d % 2 == 1 || binary_search(a, a + n, (d / 2)) == 0) {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
  cout << "YES" << endl;
}
