Didin $M$.

There are 100 piles, each with 400 stones. In one move, Petya selects two piles, removes one stone from each, and earns as many points as the absolute difference in the number of stones in these two piles. Petya must remove all the stones. What is the maximum total number of points he can earn?
Evaluation. Let's assume that the stones in the piles are stacked on top of each other, and Petya takes the top (at the moment) stones from the selected piles. We will number the stones in each pile from bottom to top with numbers from 1 to 400. Then the number of points Petya gets on each move is the difference between the numbers of the removed stones. As a result, he

![](https://cdn.mathpix.com/cropped/2024_05_06_7b30f89ee421e63350f8g-34.jpg?height=51&width=1237&top_left_y=2647&top_left_x=16)

Notice that after expanding the brackets, we get an algebraic sum of one hundred numbers 400, one hundred numbers 399, ..., one hundred twos, and one hundred ones, with a minus sign in front of exactly half of these numbers.

Let's call the numbers from 1 to 200 small, and the rest - large. If it were allowed to take any stones from the piles, then the maximum value, obviously, is achieved when all large numbers enter the sum with a plus sign, and all small numbers - with a minus sign. Such a sum is

$$
100(400+399+\ldots+201-200-199-\ldots-1)=100((400-200)+(399-199)+\ldots+(201-1))=100 \cdot 200^{2}
$$

However, note that each large number will enter the sum with a minus sign at least once: this will happen, for example, when Petya first removes a stone with this number. Similarly, each of the 200 small numbers will enter the sum with a plus sign at least once (when Petya removes the last stone with this number). Therefore, the maximum result for Petya does not exceed 99(400 + $399+\ldots+$ 201) $-$ 99(200+199+$\ldots+$1) $-$ (400+399+$\ldots+$201) + (200+199+$\ldots+$1) = 98 \cdot 200^{2}.

Example. The specified result can be achieved, for example, as follows. In the first 200 moves, Petya takes 200 stones from the first two piles (during which 200 large numbers - each once - get a minus sign). In the next 200 moves, he removes 200 top stones from the third pile and 200 bottom stones from the first pile, then 200 stones from the second and fourth piles, the third and sixth piles, ..., the 98th and 100th piles (during which all numbers enter with the "correct" signs). Finally, there are 200 bottom stones left in the last two piles, which are removed in the last 200 moves (and 200 plus signs appear before the numbers from 200 to 1).

## Answer

3920000.