Problem

Source: Mexican National Olympiad 2016

Tags: Mexico, combinatorics, Parity



The numbers from $1$ to $n^2$ are written in order in a grid of $n \times n$, one number in each square, in such a way that the first row contains the numbers from $1$ to $n$ from left to right; the second row contains the numbers $n + 1$ to $2n$ from left to right, and so on and so forth. An allowed move on the grid consists in choosing any two adjacent squares (i.e. two squares that share a side), and add (or subtract) the same integer to both of the numbers that appear on those squares. Find all values of $n$ for which it is possible to make every squares to display $0$ after making any number of moves as necessary and, for those cases in which it is possible, find the minimum number of moves that are necessary to do this.