3. Given a periodic sequence $\left\{x_{n}\right\}$ satisfying $x_{n}=\mid x_{n-1}-$ $x_{n-2} \mid(n \geqslant 3)$, if $x_{1}=1, x_{2}=a \geqslant 0$, then when the period of the sequence is the smallest, find the sum of the first 2008 terms of the sequence.
3. Solution: Let the smallest positive period of the sequence be $T$, then $T$ $\neq 1$, otherwise $x_{2}=x_{1}=1, x_{3}=\left|x_{2}-x_{1}\right|=0 \neq 1$, which is a contradiction, so $\left\{x_{n}\right\}$ cannot be a sequence with a period of 1, hence $T \geqslant$ 2.

If $T=2, x_{2} \neq x_{1}$, then $x_{3}=|a-1|=1, \therefore a$ $=2$ or $a=0$. Therefore, $x_{4}=\left|x_{3}-x_{2}\right|=|| a-1|-a|$ $=|a-1|=1=a \Rightarrow x_{1}=x_{2}$, which is a contradiction.

If $T=3$, then $x_{3}=|a-1|, x_{4}=\left|x_{3}-x_{2}\right|=$ ||$a-1|-a|=1$,
$\therefore|a-1|-a= \pm 1, \therefore|a-1|=a \pm 1$,
When $|a-1|=a-1$, $a \geqslant 1$,
When $|a-1|=a+1$, $a=0$,
$\therefore a \geqslant 1$ or $a=0$,

At this point, $x_{5}=\left|x_{4}-x_{3}\right|=|1-| a-1||=a=x_{2}$,
$\therefore 0 \leqslant a \leqslant 1, \therefore a=0$ or 1.
When $a=0$, the sequence is: $1,0,1,1,0,1,1,0$, $\cdots, S_{2008}=669 \times 2+1=1339$;

When $a=1$, the sequence is: $1,1,0,1,1,0,1,1,0$, $\cdots, S_{2008}=669 \times 2+1=1339$.