2. Define the sequence $\left\{a_{n}\right\}: a_{1}=0, a_{2}=1$,
$$
\begin{aligned}
a_{n}= & \frac{1}{2} n a_{n-1}+\frac{1}{2} n(n-1) a_{n-2}+ \\
& (-1)^{n}\left(1-\frac{n}{2}\right)(n \geqslant 3) .
\end{aligned}
$$

Find the simplest expression for $f_{n}=\sum_{k=1}^{n} k \mathrm{C}_{n}^{k-1} a_{n+1-k}$.
The goal is to derive a recurrence relation involving $f(n)$ and $f(n-1)$.
From the given conditions, we have
$$
\begin{array}{l}
a_{n}-n a_{n-1}=(-1)^{n} \Rightarrow \frac{a_{n}}{n!}=\sum_{j=0}^{n} \frac{(-1)^{j}}{j!} \\
\Rightarrow f_{n}+n+1=n f_{n-1}+n^{2}=n\left(f_{n-1}+n\right) \\
\Rightarrow f_{n}=2 n!-n-1 .
\end{array}
$$