#K49967. Magic Square Verification

    ID: 28760 Type: Default 1000ms 256MiB

Magic Square Verification

Magic Square Verification

You are given a square matrix of size \(N \times N\). A magic square is defined as a square matrix in which the sum of every row, every column, and the two main diagonals are all equal. The matrix is assumed to have distinct numbers.

Your task is to determine whether the given matrix is a magic square.

Note: Even though the classical definition of a magic square requires all numbers to be distinct, you only need to verify the equality of the sums as described and not check for uniqueness.

Input/Output Format: The program will take input from standard input (stdin) and output the result to standard output (stdout).

inputFormat

The first line contains an integer \(N\) representing the dimension of the square matrix. The following \(N\) lines each contain \(N\) space-separated integers representing a row of the matrix.

For example:

3
8 1 6
3 5 7
4 9 2

outputFormat

Output a single integer: output 1 if the matrix is a magic square, otherwise output 0.

## sample
3
8 1 6
3 5 7
4 9 2
1