On a bookshelf, 30 volumes of an encyclopedia stand in some order. In one operation, it is allowed to swap any two adjacent volumes. What is the minimum number of operations required to guarantee that all volumes can be arranged in the correct order (from the first to the thirtieth from left to right) regardless of the initial position?

#
Let's call a disorder a pair of volumes where the volume with the larger number is to the left of the volume with the smaller number. In one operation, the number of disorders changes by no more than 1.

## Solution

Suppose we have some arrangement of volumes on a shelf. Consider all possible pairs of volumes (there are a total of $30 \cdot 29: 2 = 435$ such pairs). We will call a disorder a pair of volumes where the volume with the larger number is to the left of the volume with the smaller number. In the final situation, there should be no disorders. Note that in one operation, the number of disorders changes by no more than 1. Indeed, a disorder can appear or disappear only in the pair of volumes being swapped. Therefore, in the initial arrangement where the volumes are in reverse order (each pair of volumes forms a disorder), it will take no fewer than 435 operations.

We will show that 435 operations are always sufficient. If in some arrangement of volumes there are disorders, then there will be a pair of adjacent volumes forming a disorder. By swapping this pair of volumes, we reduce the number of disorders by 1. Thus, with each operation, we can reduce the number of disorders by 1, and in no more than 435 operations, we can arrive at an arrangement with no disorders, that is, the correct order of volumes.

## Answer

In 435 operations.