IntermediateRating 1100
Magic Square
Print YES if the n×n grid is a magic square: every row, column and both diagonals have the same sum.
Input
n, then n lines.
Output
YES or NO.
Sample 1
Input
3 2 7 6 9 5 1 4 3 8
Output
YES
Sample 2
Input
2 1 2 3 4
Output
NO
Output appears here