Magic square#1364

Magic square

1 second
64 megabytes
Easy

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.

Input

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 .

Output

If the specified square is magic, output its magic constant. Otherwise, output -1.

Examples

Example 1

Loading
Loading