TITLE: $6 \times 6$ and $7 \times 7$ integer matrices
QUESTION [6 upvotes]: Can one fill a $6 \times 6$ matrix with integers so that the sum of all the numbers in each $3 \times 3$ square equals $2016$ and the sum of all the numbers in each $5 \times 5$ square equals $2015$?
Solve the same problem for the $7 \times 7$ case.

My work so far:
I solved the problem for table $6\times6$:
\begin{bmatrix}
2017 & -1 & 0 & 0 & 0 & 2017 \\
0 & -6050 & 4033 & 4034 & -6050 & -1 \\
0 & 4034 & -2017 & -2017 & 4033 & 0 \\
0 & 4033 & -2017 & -2017 & 4034 & 0 \\
-1 & -6050 & 4034 & 4033 & -6050 & 0 \\
2017 & 0 & 0 & 0 & -1 & 2017
\end{bmatrix}
Addition:

I proved that $x_1+x_2+x_3+x_4=4\cdot 2017$
$y_1+y_2+y_3+y_4=-4$
$x_1+x_3=x_2+x_4$
$S=0$
Further

Q: How to prove or disprove the existence of the table $7\times7$?

REPLY [8 votes]: Hint: in the $7 \times 7$ case, how many $3 \times 3$ squares and how many $5 \times 5$ squares contain each entry of the table?
EDIT:
OK, time's up... each entry of the $7 \times 7$ table is in the same number of  $3 \times 3$ squares as it is in $5 \times 5$ squares.  So i you take the sums of the numbers in each $3 \times 3$ square and add them up, you should get the same result as if you take the sum of the numbers in each $5 \times 5$ square and add them up.  Now, what does that tell you?