8. Let $M=\{1,2, \cdots, 2017\}$ be the set of the first 2017 positive integers. If one element is removed from the set $M$, and the sum of the remaining elements is exactly a perfect square, then the removed element is
8. 1677.

Notice,
$$
\begin{array}{l}
1+2+\cdots+2017=\frac{2017 \times 2018}{2} \\
>[\sqrt{2017 \times 1009}]^{2}=1426^{2} \\
=2033476 . \\
\text { Then } \frac{2017 \times 2018}{2}-2033476=1677 .
\end{array}
$$