2. Determine for which natural numbers $n$ it is possible to fill an $n \times n$ table with numbers $2a-1$ in such a way that the sum of all numbers in each row and each column is equal to 0. (Ján Mazák)
SOLUTION. Let us choose any row (or column) of the $n \times n$ square table, which is filled with numbers $2 \mathrm{a}-1$. Let $d$ be the number of 2s and $p$ be the number of -1s in it. Then $d+p=n$ and according to the problem statement, it must also hold that $2 d-p=0$. By adding these two equations, we get $3 d=n$, which means that the number $n$ must be divisible by three, i.e., $n=3 k$, where $k$ is a natural number.

We will show that this condition is also sufficient. For any $n=3 k$, we can divide the $n \times n$ table in an obvious way into $k^{2}$ smaller $3 \times 3$ square tables. It is easy to see that each of these smaller $3 \times 3$ tables can be filled in the required way - for example, by writing the number 2 in all three fields of one of its diagonals and the number -1 in the six remaining fields of this table. The entire $n \times n$ square table then satisfies the condition of the problem because each of the $k^{2}$ created $3 \times 3$ tables satisfies it.

Conclusion. The given method can fill exactly those $n \times n$ tables where $n$ is a natural number divisible by three.

## GUIDING AND ADDITIONAL PROBLEMS:

N1. Decide whether a $3 \times 3$ square table can be filled with natural numbers from 1 to 9 such that each number is used exactly once and the sum of all numbers in each row and each column is divisible by a) two, b) three. [a) No — if the sum of the numbers in each row of the table were divisible by two, the sum of all numbers in the table would also be divisible by two. However, their sum is 45. b) Yes — it is easy to find a specific example.]

N2. Decide for which natural numbers $n$ a $n \times n$ square table can be filled with the numbers 1 and -1 such that the sum of all numbers in each row and each column is equal to 0. [For every even number $n$, the table $n \times n$ can be filled as required in the pattern of a black and white chessboard. For odd $n$, this is not possible, because in no row (column) can there be the same number of -1s and 1s.]

N3. Decide whether a $3 \times 3$ square table can be filled with natural numbers from 1 to 9 such that each number is used exactly once and the sum of all numbers in each row, each column, and both diagonals is the same (we get a so-called magic square). [Since the sum of the given nine numbers is 45, the sum of all numbers in each row and each column must be $45: 3=15$, which is an odd number. There is one more odd number than even numbers in the table. Additionally, $1+9=2+8=3+7=4+6=10$. Therefore, if the number 5 is in the middle of the table, it is easy to find a specific example of a possible way to fill this table.]

D1. A $3 \times 3$ table is filled with different natural numbers such that in each row and column, the sum of the extreme numbers is equal to the number written between them. Determine the smallest number that can be written in the middle of the table. [69-C-S-2]

D2. In how many ways can the numbers $\{1,2,3,4,5,6\}$ be written into the fields of a $2 \times 3$ table such that each is used exactly once and the sum of all numbers in each row and each column is divisible by three? [Math Kangaroo 2018, Junior category, problem 21 (48 possibilities).]