9. (16 points) Given the sequence $\left\{a_{n}\right\}$ satisfies:
$$
\begin{array}{l}
a_{1}=1, a_{2}=2, a_{3}=4, \\
a_{n}=a_{n-1}+a_{n-2}-a_{n-3}+1(n \geqslant 4) .
\end{array}
$$
(1) Find the general term formula for the sequence $\left\{a_{n}\right\}$;
(2) Prove: $\frac{1}{a_{1}}+\frac{1}{a_{2}}+\cdots+\frac{1}{a_{2016}}<3$.
(1) For $n \geqslant 4$, summing up we get
$$
a_{n}-a_{n-2}=a_{3}-a_{1}+n-3=n \text {. }
$$

When $n=2 m\left(m \in \mathbf{Z}_{+}\right)$,
$$
\begin{aligned}
a_{n}= & a_{2}+\sum_{k=1}^{m-1}\left(a_{2 k+2}-a_{2 k}\right) \\
& =2+\sum_{k=1}^{m-1}(2 k+2)=\frac{1}{4} n(n+2) ;
\end{aligned}
$$

When $n=2 m+1\left(m \in \mathbf{Z}_{+}\right)$,
$$
a_{n}=a_{1}+\sum_{k=1}^{m}\left(a_{2 k+1}-a_{2 k-1}\right)=\frac{1}{4}(n+1)^{2} \text {. }
$$

Thus, $a_{n}=\left\{\begin{array}{ll}\frac{1}{4}(n+1)^{2}, & n \text { is odd; } \\ \frac{1}{4} n(n+2), & n \text { is even. }\end{array}\right.$
(2) When $n$ is odd,
$$
\begin{array}{l}
\frac{1}{a_{n}}=\frac{4}{(n+1)^{2}}<\frac{4}{(n-1)(n+1)} \\
=2\left(\frac{1}{n-1}-\frac{1}{n+1}\right) ;
\end{array}
$$

When $n$ is even,
$$
\begin{array}{l}
\frac{1}{a_{n}}=\frac{4}{n(n+2)}=2\left(\frac{1}{n}-\frac{1}{n+2}\right) . \\
\text { Therefore, } \frac{1}{a_{1}}+\frac{1}{a_{2}}+\cdots+\frac{1}{a_{2016}} \\
=\left(\frac{1}{a_{1}}+\frac{1}{a_{3}}+\cdots+\frac{1}{a_{2015}}\right)+ \\
\quad\left(\frac{1}{a_{2}}+\frac{1}{a_{4}}+\cdots+\frac{1}{a_{2016}}\right) \\
<\left[1+2\left(\frac{1}{2}-\frac{1}{2016}\right)\right]+2\left(\frac{1}{2}-\frac{1}{2018}\right)<3 .
\end{array}
$$