On the coordinate line, the points with coordinates $0,1,2, \ldots, 2 n-1$ are marked, where $n$ is a positive integer. A flea starts jumping from the point with coordinate 0 and after $2 n$ jumps returns there, having visited all the marked points. It is known that the total length of all jumps except the last one is $n(2 n-1)$. Find the length of the last jump.
We claim that the length of the path formed by the first $2 n-1$ jumps cannot exceed $n(2 n-1)$. To prove this, take a path of maximal length (which exists because there are only finitely many paths the flea can take). Note that there cannot be three successive stations $a_{1}, a_{2}$, $a_{3}$ on the path with monotonic order $\left(a_{1}a_{2}>a_{3}$, since then the path could be lengthened by jumping directly from $a_{1}$ to $a_{3}$ and postponing the trip to $a_{2}$ to the end of the path. Therefore the path consists of a zigzag sequence of marked points

$$
0\ell_{1}\ell_{2}\ell_{n-1}<r_{n}
$$

and its length is

$$
\begin{aligned}
& \left(r_{1}-0\right)+\left(r_{1}-\ell_{1}\right)+\left(r_{2}-\ell_{1}\right)+\cdots+\left(r_{n-1}-\ell_{n-1}\right)+\left(r_{n}-\ell_{n-1}\right) \\
& =2\left(r_{1}+\cdots+r_{n-1}\right)+r_{n}-2\left(\ell_{1}+\cdots+\ell_{n-1}\right) .
\end{aligned}
$$

Writing this as

$$
\left(r_{1}+\cdots+r_{n-1}\right)+\left(r_{1}+\cdots+r_{n}\right)-2\left(\ell_{1}+\cdots+\ell_{n-1}\right)
$$

makes apparent that it is at most

$$
\begin{aligned}
& ((2 n-1)+\cdots+(n+1))+((2 n-1)+\cdots+n)-2(1+\cdots+(n-1)) \\
& =(\underbrace{(2 n-1)-(n-1)}_{n})+\cdots+(\underbrace{n+1-1}_{n})+(\underbrace{(2 n-1)-(n-1)}_{n}+\cdots+(\underbrace{n+1-1}_{n})+n \\
& =n(2 n-1) .
\end{aligned}
$$

In order for the path to achieve a length of $n(2 n-1)$, all our inequalities must be equalities. In particular, the equalities

$$
r_{1}+\cdots+r_{n-1}=(2 n-1)+\cdots+(n+1) \quad \text { and } \quad r_{1}+\cdots+r_{n}=(2 n-1)+\cdots+n
$$

yield $r_{n}=n$. Hence the final jump from $r_{n}$ back to 0 has length $n$.