11. (14 points) In the sequence $\left\{a_{n}\right\}$,
$$
a_{1}=1, a_{n+1}=2 a_{n}-n+2\left(n \in \mathbf{Z}_{+}\right) \text {. }
$$

Find the sum of the first $n$ terms $S_{n}$ of the sequence $\left\{a_{n}\right\}$.
II. 11. From $a_{n+1}=2 a_{n}-n+2$, we get
$$
a_{n+1}-n=2\left[a_{n}-(n-1)\right] \text {. }
$$

Therefore, the sequence $\left\{a_{n}-(n-1)\right\}$ is a geometric sequence with the first term 1 and common ratio 2.
Thus, $a_{n}=2^{n-1}+n-1$.
Hence, the sum of the first $n$ terms of the sequence $\left\{a_{n}\right\}$ is
$$
S_{n}=2^{n}-1+\frac{n(n-1)}{2} .
$$