3. Given the sequence $\left\{a_{n}\right\}$ satisfies
$$
a_{1}=0,\left|a_{n+1}\right|=\left|a_{n}-2\right| \text {. }
$$

Let the sum of the first 2016 terms of the sequence $\left\{a_{n}\right\}$ be $S$. Then the maximum value of $S$ is $\qquad$