A magic square is a square table filled with n^2 numbers such that the sum of the numbers in each row, each column, and both diagonals is the same. This common sum is called the magic constant. You are to check whether the given square is magic.

The first line contains the integer (1 \le n \le 100). The next lines contain integers each. All numbers in the square are natural numbers not exceeding .
If the specified square is magic, output its magic constant. Otherwise, output -1.
Example 1