For what $n$s is it possible to write a $1$, $2$ or a $3$ into each cell of a $n\times n$ square, such that each of the three numbers appears equal number of times in every row, column, and diagonal, only if the number of cells of the diagonal is divisible by 3?
I think it appeared in an IMO contest or shortlist about year 2006, but I couln’t find or solve it.
This came from IMO Question 2. I'll summarise the official solution here: