18. Lonely Cars. (From 9th grade, 4 points.) On a very long narrow highway, where overtaking is impossible, $n$ cars are driving in a random order, each with its own preferred speed. If a fast car catches up to a slower one, the fast car has to slow down and drive at the same speed as the slower one. Thus, the cars form groups. Find the expected number of "lonely" cars, that is, groups consisting of a single car.
Solution. Let $I_{k}$ be the indicator of the event "the $k$-th car in line is alone." For $k \leq n$, this event consists of the slowest car among the first $k+1$ cars being the last, and the second slowest being the second to last. The probability of this is $\frac{1}{(k+1) k}$. If $k=n$, then this event consists of the slowest car being the last (probability $\frac{1}{n}$).

The random variable $X$ "number of lonely cars" is equal to the sum of all indicators, therefore

$$
\begin{gathered}
\mathrm{E} X=\mathrm{E} I_{1}+\mathrm{E} I_{2}+\ldots+\mathrm{E} I_{n}=\frac{1}{1 \cdot 2}+\frac{1}{2 \cdot 3}+\ldots .+\frac{1}{(n-1) n}+\frac{1}{n}= \\
=1-\frac{1}{2}+\frac{1}{2}-\frac{1}{3}+\frac{1}{3}-\ldots+\frac{1}{n-1}-\frac{1}{n}+\frac{1}{n}=1
\end{gathered}
$$

Answer: 1.