Vanya wrote the number 1 on the board, and then several more numbers. As soon as Vanya writes the next number, Mitya calculates the median of the existing set of numbers and writes it down in his notebook. At some point, the numbers in Mitya's notebook are: $1 ; 2 ; 3 ; 2.5 ; 3 ; 2.5 ; 2 ; 2 ; 2 ; 5$.

a) What number is written on the board fourth

b) What number is written on the board eighth

#
a) The first number is obviously one. Then, for the median of the first two numbers to be 2, the second number must be 3.

For clarity, let's write down Vanya's numbers. Vanya wrote the third number $a$: $13 a_{3}$. The median is now 3, which can only be if $a \geq 3$. Add another number: $13 a \geq 3 b$.

The median of the resulting set, according to the condition, is 2.5. This can only be if $b=2$.

b) Let's add a fifth number and get the sequence $123 a \geq 3 c$. The median is 3, so $c \geq 3$.

Add a sixth number: $123 a \geq 3 c \geq 3 d$. The median has decreased to 2.5 again. Therefore, $d \leq 2$.

Add a seventh number $e$: $1 d \leq 223 a \geq 3 c \geq 3 e$. Now the median is 2. It is clear that $e \leq 2$, otherwise the number of numbers not greater than two will be 3, which is less than half of the total number of numbers. Add an eighth number: $1 d \leq 2 e \leq 223 a \geq 3 c \geq 3 f$.

The median is 2 again. Therefore, $f \leq 2$. In this case, if one of the numbers $d, e$ is 2, then $f$ can be any number not greater than 2. If both $d$ and $e$ are less than 2, then $f=2$.

In any case, we get a sequence of the form $1 x \leq 2 y \leq 223 a \leq 3 c \leq 3$. This does not contradict the conditions of the problem: if Vanya writes two more threes, then the ninth median will be 2, and the tenth will be 2.5.

## Answer

a) 2; b) if the sixth or seventh number is 2, then the eighth number is not more than 2; if both the sixth and seventh numbers are less than 2, then the eighth number is 2. Other options are not possible.