(given to Juliette Fournier). What is the maximum number of subsequences of the form $n, n+1, n+2$ that a sequence of 2007 natural numbers can have? For example, the sequence $1,2,2,3,3$ has 4 subsequences of this nature.
. The answer is $\left(\frac{2007}{3}\right)^{3}=669^{3}$, obtained by taking the sequence formed of 669 times the number 1, 669 times the number 2, and 669 times the number 3. We show this step by step. Let $x_{1}, \ldots, x_{n}$ be a sequence achieving this maximum. We can first assume the sequence is increasing. Indeed, swapping two consecutive terms that are in decreasing order can only increase the number of the desired subsequences. Next, we can assume that two consecutive terms of the sequence differ by at most 1. Indeed, if $x_{i}=X_{i-1}+a$, with $a \geqslant 2$, subtracting $a-1$ from all terms of the sequence from $x_{i}$ onward can only increase the number of the desired subsequences. Therefore, we can assume that the sequence consists of $a_{1}$ times the number 1, $a_{2}$ times the number 2, etc., up to $a_{r}$ times the number $r$, the sum of the $a_{i}$ being 2007. The number of the desired subsequences is $a_{1} a_{2} a_{3}+a_{2} a_{3} a_{4}+\ldots+a_{r-2} a_{r-1} a_{r}$. We immediately see that we have $a_{r-2} \geqslant a_{r-1} \geqslant a_{r}$. Thus, if $r \geqslant 4$, replacing all $r$ with $r-1$ increases the number of the desired subsequences. Therefore, we have $r=3$. Applying the arithmetic-geometric inequality, we find that the sequence must contain as many 1s as 2s and 3s. This concludes the proof.