#include using namespace std; int main(void) { int N; cin >> N; vector> D(N, vector(N)); for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ cin >> D[i][j]; } } bool property1 = true; bool property2 = true; bool property3 = true; bool property4 = true; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(i == j && D[i][j] != 0) property1 = false; if(i != j && D[i][j] == 0) property1 = false; } } for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(D[i][j] != D[j][i]) property2 = false; } } for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ for(int k = 0; k < N; k++){ if(D[i][j] > D[i][k] + D[k][j]){ property3 = false; } } } } for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ for(int k = 0; k < N; k++){ if(D[i][j] > max(D[i][k], D[k][j])){ property4 = false; } } } } if(property1 && property2 && property3){ cout << "Yes" << endl; } else { cout << "No" << endl; } if(property1 && property2 && property4){ cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }