Example 1.7 Find the number of all permutations of $n$ distinct elements $a_{1}, a_{2}, \cdots, a_{n}$ in which $a_{1}$ and $a_{2}$ are not adjacent.
Solution: Let the required number be $N$. Since the total number of permutations formed by $a_{1}, a_{2}, \cdots, a_{n}$ is $n$!, among which the permutations where $a_{1}$ and $a_{2}$ are not adjacent are $N$, and the permutations where $a_{1}$ and $a_{2}$ are adjacent are $2 \cdot(n-1)$!, by the principle of addition, we have

Therefore,
$$
N+2 \cdot(n-1)!=n!\text {, }
$$
$$
\begin{aligned}
N & =n!-2(n-1)! \\
& =(n-2)(n-1)!.
\end{aligned}
$$