Problem (Algebra):
Let $n$ be a fixed positive integer. Find the maximum possible value of

$$
\sum_{1 \leqslant r<s \leqslant 2 n}(s-r-n) x_{r} x_{s}
$$

where $-1 \leqslant x_{i} \leqslant 1$ for all $i=1,2, \ldots, 2 n$.

Solution:
Let $Z$ be the expression to be maximized. Since this expression is linear in every variable $x_{i}$ and $-1 \leqslant x_{i} \leqslant 1$, the maximum of $Z$ will be achieved when $x_{i}=-1$ or 1 . Therefore, it suffices to consider only the case when $x_{i} \in\{-1,1\}$ for all $i=1,2, \ldots, 2 n$.

For $i=1,2, \ldots, 2 n$, we introduce auxiliary variables

$$
y_{i}=\sum_{r=1}^{i} x_{r}-\sum_{r=i+1}^{2 n} x_{r}
$$

Taking squares of both sides, we have

$$
\begin{aligned}
y_{i}^{2} & =\sum_{r=1}^{2 n} x_{r}^{2}+\sum_{r<s \leqslant i} 2 x_{r} x_{s}+\sum_{i<r<s} 2 x_{r} x_{s}-\sum_{r \leqslant i<s} 2 x_{r} x_{s} \\
& =2 n+\sum_{r<s \leqslant i} 2 x_{r} x_{s}+\sum_{i<r<s} 2 x_{r} x_{s}-\sum_{r \leqslant i<s} 2 x_{r} x_{s},
\end{aligned}
\tag{1}
$$

where the last equality follows from the fact that $x_{r} \in\{-1,1\}$. Notice that for every $r<s$, the coefficient of $x_{r} x_{s}$ in (1) is 2 for each $i=1, \ldots, r-1, s, \ldots, 2 n$, and this coefficient is -2 for each $i=r, \ldots, s-1$. This implies that the coefficient of $x_{r} x_{s}$ in $\sum_{i=1}^{2 n} y_{i}^{2}$ is $2(2 n-s+r)-2(s-r)=$ $4(n-s+r)$. Therefore, summing (1) for $i=1,2, \ldots, 2 n$ yields

$$
\sum_{i=1}^{2 n} y_{i}^{2}=4 n^{2}+\sum_{1 \leqslant r<s \leqslant 2 n} 4(n-s+r) x_{r} x_{s}=4 n^{2}-4 Z
\tag{2}
$$

Hence, it suffices to find the minimum of the left-hand side.

Since $x_{r} \in\{-1,1\}$, we see that $y_{i}$ is an even integer. In addition, $y_{i}-y_{i-1}=2 x_{i}= \pm 2$, and so $y_{i-1}$ and $y_{i}$ are consecutive even integers for every $i=2,3, \ldots, 2 n$. It follows that $y_{i-1}^{2}+y_{i}^{2} \geqslant 4$, which implies

$$
\sum_{i=1}^{2 n} y_{i}^{2}=\sum_{j=1}^{n}\left(y_{2 j-1}^{2}+y_{2 j}^{2}\right) \geqslant 4 n
\tag{3}
$$

Combining (2) and (3), we get

$$
4 n \leqslant \sum_{i=1}^{2 n} y_{i}^{2}=4 n^{2}-4 Z
\tag{4}
$$

Hence, $Z \leqslant n(n-1)$.

If we set $x_{i}=1$ for odd indices $i$ and $x_{i}=-1$ for even indices $i$, then we obtain equality in (3) (and thus in (4)). Therefore, the maximum possible value of $Z$ is $n(n-1)$, as desired.

We present a different method of obtaining the bound $Z \leqslant n(n-1)$. As in the previous solution, we reduce the problem to the case $x_{i} \in\{-1,1\}$. For brevity, we use the notation $[2 n]=\{1,2, \ldots, 2 n\}$.

Consider any $x_{1}, x_{2}, \ldots, x_{2 n} \in\{-1,1\}$. Let

$$
A=\left\{i \in[2 n]: x_{i}=1\right\} \quad \text { and } \quad B=\left\{i \in[2 n]: x_{i}=-1\right\}
$$

For any subsets $X$ and $Y$ of $[2 n]$ we define

$$
e(X, Y)=\sum_{r<s, r \in X, s \in Y}(s-r-n)
$$

One may observe that

$$
e(A, A)+e(A, B)+e(B, A)+e(B, B)=e([2 n],[2 n])=\sum_{1 \leqslant r<s \leqslant 2 n}(s-r-n)=-\frac{(n-1) n(2 n-1)}{3}
$$

Therefore, we have

$$
Z=e(A, A)-e(A, B)-e(B, A)+e(B, B)=2(e(A, A)+e(B, B))+\frac{(n-1) n(2 n-1)}{3} .
\tag{5}
$$

Thus, we need to maximize $e(A, A)+e(B, B)$, where $A$ and $B$ form a partition of $[2 n]$.

Due to the symmetry, we may assume that $|A|=n-p$ and $|B|=n+p$, where $0 \leqslant p \leqslant n$. From now on, we fix the value of $p$ and find an upper bound for $Z$ in terms of $n$ and $p$.

Let $a_{1}<a_{2}<\cdots<a_{n-p}$ and $b_{1}<b_{2}<\cdots<b_{n+p}$ list all elements of $A$ and $B$, respectively. Then

$$
e(A, A)=\sum_{1 \leqslant i<j \leqslant n-p}\left(a_{j}-a_{i}-n\right)=\sum_{i=1}^{n-p}(2 i-1-n+p) a_{i}-\left(\begin{array}{c}
n-p \\
2
\end{array}\right) \cdot n
\tag{6}
$$

and similarly

$$
e(B, B)=\sum_{i=1}^{n+p}(2 i-1-n-p) b_{i}-\left(\begin{array}{c}
n+p \\
2
\end{array}\right) \cdot n
\tag{7}
$$

Thus, now it suffices to maximize the value of

$$
M=\sum_{i=1}^{n-p}(2 i-1-n+p) a_{i}+\sum_{i=1}^{n+p}(2 i-1-n-p) b_{i}
\tag{8}
$$

In order to get an upper bound, we will apply the rearrangement inequality to the sequence $a_{1}, a_{2}, \ldots, a_{n-p}, b_{1}, b_{2}, \ldots, b_{n+p}$ (which is a permutation of $1,2, \ldots, 2 n$ ), together with the sequence of coefficients of these numbers in (8). The coefficients of $a_{i}$ form the sequence

$$
n-p-1, n-p-3, \ldots, 1-n+p
$$

and those of $b_{i}$ form the sequence

$$
n+p-1, n+p-3, \ldots, 1-n-p
$$



Altogether, these coefficients are, in descending order:

- $n+p+1-2 i$, for $i=1,2, \ldots, p$;
- $n-p+1-2 i$, counted twice, for $i=1,2, \ldots, n-p$; and
- $-(n+p+1-2 i)$, for $i=p, p-1, \ldots, 1$.

Thus, the rearrangement inequality yields

$$
\begin{gathered}
M \leqslant \sum_{i=1}^{p}(n+p+1-2 i)(2 n+1-i) \\
\quad+\sum_{i=1}^{n-p}(n-p+1-2 i)((2 n+2-p-2 i)+(2 n+1-p-2 i)) \\
\quad-\sum_{i=1}^{p}(n+p+1-2 i) i .
\end{gathered}
\tag{9}
$$

Finally, combining the information from (5), (6), (7), and (9), we obtain

$$
\begin{aligned}
Z \leqslant & \frac{(n-1) n(2 n-1)}{3}-2 n\left(\left(\begin{array}{c}
n-p \\
2
\end{array}\right)+\left(\begin{array}{c}
n+p \\
2
\end{array}\right)\right) \\
& +2 \sum_{i=1}^{p}(n+p+1-2 i)(2 n+1-2 i)+2 \sum_{i=1}^{n-p}(n-p+1-2 i)(4 n-2 p+3-4 i)
\end{aligned}
$$

which can be simplified to

$$
Z \leqslant n(n-1)-\frac{2}{3} p(p-1)(p+1)
$$

Since $p$ is a nonnegative integer, this yields $Z \leqslant n(n-1)$.

Final answer: $n(n-1)$