Problem

10 /12


Magic square?

Problem

Order magic square N is a square matrix of size NxN , composed of numbers 1, 2< /code>, ..., NxN so that the sums for each column, each row and each of the two large diagonals are equal to each other. Write a program that checks if a given square matrix is ​​a magic square.

Input data 
The first line enters the size of the matrix N (\(0<N<=100\)) . The following N lines contain matrix rows, each with N values ​​separated by spaces.

Imprint
The program should output the word 'YES' if the matrix is ​​a magic square, and the word 'NO' if it is not.

 
Example
# Input Output
1 3
8 1 6
3 5 7
4 9 2
YES