Problem (Combinatorics):
The $n$ contestants of an EGMO are named $C_{1}, \ldots, C_{n}$. After the competition they queue in front of the restaurant according to the following rules.

- The Jury chooses the initial order of the contestants in the queue.
- Every minute, the Jury chooses an integer $i$ with $1 \leq i \leq n$.
    - If contestant $C_{i}$ has at least $i$ other contestants in front of her, she pays one euro to the Jury and moves forward in the queue by exactly $i$ positions.
    - If contestant $C_{i}$ has fewer than $i$ other contestants in front of her, the restaurant opens and the process ends.
Determine for every $n$ the maximum number of euros that the Jury can collect by cunningly choosing the initial order and the sequence of moves.

Solution:
The maximal number of euros is $2^{n}-n-1$.

To begin with, we show that it is possible for the Jury to collect this number of euros. We argue by induction. Let us assume that the Jury can collect $M_{n}$ euros in a configuration with $n$ contestants. Then we show that the Jury can collect at least $2 M_{n}+n$ moves in a configuration with $n+1$ contestants. Indeed, let us begin with all the contestants lined up in reverse order. In the first $M_{n}$ moves the Jury keeps $C_{n+1}$ in first position and reverses the order of the remaining contestants, then in the next $n$ moves all contestants $C_{1}, \ldots, C_{n}$ (in this order) jump over $C_{n+1}$ and end up in the first $n$ positions of the line in reverse order, and finally in the last $M_{n}$ moves the Jury rearranges the first $n$ positions.

Since $M_{1}=0$ and $M_{n+1} \geq 2 M_{n}+n$, an easy induction shows that $M_{n} \geq 2^{n}-n-1$.



Let us show now that at most $2^{n}-n-1$ moves are possible. To this end, let us identify a line of contestants with a permutation $\sigma$ of $\{1, \ldots, n\}$. To each permutation we associate the set of reverse pairs

$$
R(\sigma):=\{(i, j): 1 \leq i<j \leq n \text { and } \sigma(i)>\sigma(j)\}
$$

and the nonnegative integer

$$
W(\sigma):=\sum_{(i, j) \in R(\sigma)} 2^{i}
$$

which we call the total weight of the permutation. We claim that the total weight decreases after any move of the contestants. Indeed, let us assume that $C_{i}$ moves forward in the queue, let $\sigma$ be the permutation before the move, and let $\sigma^{\prime}$ denote the permutation after the move. Since $C_{i}$ jumps over exactly $i$ contestants, necessarily she jumps over at least one contestant $C_{j}$ with index



$j>i$. This means that the pair $(i, j)$ is reverse with respect to $\sigma$ but not with respect to $\sigma^{\prime}$, and this yields a reduction of $2^{i}$ in the total weight. On the other hand, the move by $C_{i}$ can create new reverse pairs of the form $(k, i)$ with $k<i$, but their total contribution is at most

$$
2^{0}+2^{1}+\ldots+2^{i-1}=2^{i}-1
$$

In conclusion, when passing from $\sigma$ to $\sigma^{\prime}$, at least one term $2^{i}$ disappears from the computation of the total weight, and the sum of all the new terms that might have been created is at most $2^{i}-1$. This shows that $W\left(\sigma^{\prime}\right) \leq W(\sigma)-1$.

We conclude by observing that the maximum possible value of $W(\sigma)$ is realized when all pairs are reverse, in which case

$$
W(\sigma)=\sum_{i=1}^{n}(i-1) 2^{i}=2^{n}-n-1
$$

This proves that the number of moves is less than or equal to $2^{n}-n-1$, and in particular it is finite.

Final answer: $2^{n}-n-1$