2. (5-7) Sergei collects toy trains. He has several sets, each with a different number of cars. If all the sets are combined into one train, there will be 112 cars. If you take the three smallest sets, there will be 25 cars in them, and in the three largest - 50 cars. How many sets does Sergei have? How many cars are in the largest set?
Answer: 9 sets. 18 or 19 cars.

Solution: Let $a_{1}, a_{2}, \ldots, a_{n}$ be the number of cars in the sets, ordered in ascending order. Note that $a_{3} \geqslant 9$, otherwise the total length of the three smallest sets would be less than $a_{1}+a_{2}+a_{3} \leqslant 7+8+9=2450$.

Thus, the remaining $112-50-25=37$ cars form sets whose lengths are in the range from 10 to 15. If we assume that the number of these sets is 1 or 2, then their total length is no more than 30. And if we assume that there are 4 or more, then their total length will be more than 40. Therefore, the number of such sets is 3, and thus the total number of sets is 9.

Since $a_{7} \leqslant 16$, then $a_{8}+a_{9} \geqslant 50-16=34$. This is only possible when $a_{9} \geqslant 18$. The case $a_{9}>19$ is impossible, because then $a_{7}+a_{8}<50-19=31$, so $a_{7} \leqslant 14$, therefore, $a_{4}+a_{5}+a_{6} \leqslant 11+12+13=36<37$. It can be shown that both cases are possible by explicitly indicating the lengths: $\{7,8,10,11,12,14,15,17,18\}$ and $\{7,8,10,11,12,14,15,16,19\}$.