24. Find the number of permutations $a_{1} a_{2} a_{3} a_{4} a_{5} a_{6}$ of the six integers from 1 to 6 such that for all $i$ from 1 to $5, a_{i+1}$ does not exceed $a_{i}$ by 1 .
24. Answer: 309
Let $S$ be the set of permutations of the six integers from 1 to 6 . Then $|S|=6!=720$. Define $P(i)$ to be the subset of $S$ such that the digit $i+1$ follows immediately $i, i=1,2,3,4,5$.

Then
$$
\begin{array}{l}
\sum_{i}|P(i)|=\binom{5}{1} 5! \\
\sum_{i_{1}<i_{2}}\left|P\left(i_{1}\right) \cap P\left(i_{2}\right)\right|=\binom{5}{2} 4! \\
\sum_{i_{1}<i_{2}<i_{3}}\left|P\left(i_{1}\right) \cap P\left(i_{2}\right) \cap P\left(i_{3}\right)\right|=\binom{5}{3} 3! \\
\sum_{i_{1}<i_{2}<i_{3}<i_{4}}\left|P\left(i_{1}\right) \cap P\left(i_{2}\right) \cap P\left(i_{3}\right) \bigcap P\left(i_{4}\right)\right|=\binom{5}{4} 2! \\
|P(1) \bigcap P(2) \cap P(3) \cap P(4) \bigcap P(5)|=\binom{5}{5} 1!.
\end{array}
$$

By the Principle of Inclusion and Exclusion, the required number is
$$
6!-\binom{5}{1} 5!+\binom{5}{2} 4!-\binom{5}{3} 3!+\binom{5}{4} 2!-\binom{5}{5} 1!=309 .
$$