II. (40 points) Given the sequence of real numbers $\left\{a_{n}\right\}$ satisfies
$$
a_{1}=\frac{1}{3}, a_{n+1}=2 a_{n}-\left[a_{n}\right],
$$

where $[x]$ denotes the greatest integer less than or equal to the real number $x$.
$$
\text { Find } \sum_{i=1}^{2012} a_{i} \text {. }
$$
$$
\text { II. } a_{1}=\frac{1}{3}, a_{2}=\frac{2}{3}, a_{3}=\frac{4}{3}, a_{4}=\frac{5}{3} .
$$

By mathematical induction, it is easy to prove
$$
\left\{\begin{array}{l}
a_{2 k+1}=\frac{3 k+1}{3}, \\
a_{2 k+2}=\frac{3 k+2}{3} .
\end{array}\right.
$$

Then $a_{2 k+1}+a_{2 k+2}=2 k+1$.
Therefore, $\sum_{i=1}^{2012} a_{i}=1012036$.