3. Arrange $1,2, \cdots, 40$ into a sequence $\left\{a_{n}\right\}$, such that the first term greater than $a_{20}$ is $a_{31}$. How many such sequences are there?
3. First, choose 31 numbers from $1,2, \cdots, 40$ as the first 31 terms, there are $\mathrm{C}_{40}^{31}$ ways to do this. The largest of the first 31 terms is $a_{31}$, the second largest is $a_{20}$, and the other 29 numbers can be arranged in any order, which gives $29!$ choices. The last 9 numbers still have $9!$ arrangements. By the multiplication principle, there are $\mathrm{C}_{40}^{31} \times 29! \times 9!$ ways in total.