For what $n$ can the values of the variables $x_{1}, x_{2}, \ldots, x_{n}$ be chosen from the set $\{+1 ;-1\}$ so that $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+$ $\ldots+x_{n-1} x_{n}+x_{n} x_{1}=0$ holds?
I. solution. Following the cyclic nature of the numbering, let's introduce the notation $x_{n+1}=x_{1}$. Let $i$ be any fixed value from $1,2, \ldots, n$, and let's examine the behavior of the sum $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+\ldots+x_{n-1} x_{n}+x_{n} x_{1}$ in the case where the variables can take the values $\pm 1$, and after such an assignment, we change the sign of $x_{i}$. The change in $x_{i}$ affects only two (adjacent) terms of the sum, so it is sufficient to track the sequence of $x_{i-1} x_{i}+x_{i} x_{i+1}$. The values of $x_{i-1}, x_{i}, x_{i+1}$ are 1 or -1, so the values of the products can only be 1 or -1; accordingly, $x_{i-1} x_{i}+x_{i} x_{i+1}$ can only take the values $-2,0$ or 2. The sum of the two products is exactly -2 if and only if both products are -1, which means that the sign of $x_{i}$ is opposite to the signs of $x_{i-1}$ and $x_{i+1}$. Thus, if we change the sign of $x_{i}$, then due to $x_{i-1}=x_{i}=x_{i+1}$, the value of the sum changes from -2 to 2. Reversing the sequence of events, we can say that if initially $x_{i-1} x_{i}+x_{i} x_{i+1}=2$ - which is true if and only if $x_{i-1}=x_{i}=x_{i+1}$ - then after changing the sign of $x_{i}$, the new value of the sum is -2. Similarly, it can be seen, or derived by formal logical reasoning, that if $x_{i-1} x_{i}+x_{i} x_{i+1}=0$, then the value of the sum remains 0 even after changing the sign of $x_{i}$. This proves that the value of the expression $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+\ldots+x_{n-1} x_{n}+x_{n} x_{1}$ always changes by 0 or $\pm 4$ when the -1 multiple of one of the $x_{i}$ is used instead.

Now suppose that $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+\ldots+x_{n-1} x_{n}+x_{n} x_{1}=0$. Change the negative $x_{i}$ values to +1 one by one; thus, in the end, when each is 1, $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+\ldots+x_{n-1} x_{n}+x_{n} x_{1}=n$ will be. The change in each step was divisible by 4, so the final difference, $n-0=n$, is also divisible by 4.

Conversely: suppose that $n$ is divisible by 4, i.e., $n=4 k$. Let then $x_{4 t+1}=1, x_{4 t+2}=-1, x_{4 t+3}=1$, $x_{4 t}=1\left(t=0,1, \ldots, k\right)$. Then in the sum $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+\ldots+x_{n-1} x_{n}+x_{n} x_{1}$, two -1 valued products are always followed by two 1 valued products, so the sum is zero.

Thus, the requirement of the problem is precisely met by the numbers $n$ divisible by 4.

Remark. In the case where $n$ is divisible by 4, the value of the sum can be zero with many other constructions; however, we do not detail these. However, we show another approach to the part of the solution that the condition $4 \mid n$ is necessary.

II. solution. In the sequence $x_{1}, x_{2}, x_{3}, x_{4}, \ldots, x_{n-1}, x_{n}, x_{1}$, we speak of a sign change if for some $1 \leq j \leq n$ the signs of $x_{j}$ and $x_{j+1}$ are different. The necessary and sufficient condition for a sign change is that the value of the product $x_{j} x_{j+1}$ be -1. If the number of sign changes is $V$, then $x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+\ldots+x_{n-1} x_{n}+x_{n} x_{1}=(-1) \cdot V+1 \cdot(n-V)=n-2 V$. Thus, if the value of the above expression is 0, then $n=2 V$ is even. On the other hand, the first and last elements of the sequence are equal, so the number of sign changes $V$ is necessarily even, i.e., $n$ is divisible by 4.