A magic square is a n×n square grid filled with distinct positive integers in the range 1, 2, ... n2
such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal.
Write a program that inputs a square and then checks that it is a magic square. The first line of input is the number of rows/columns n. The rest of the input is the square of integers. If it is a magic square then output "magic = X" where X is the sum of a row/column. Else output "invalid".