Residues of 2017

Let $$S$$ be the sum of all integers $$1 \leq n \leq 2016$$ that are quadratic residues modulo 2017. What are the last three digits of $$S$$?

• You may use the fact that 2017 is a prime number.
×