Three Smallest Integers Greater Than 1000 Which Cannot Be Written as the Sum of Three Squares

Integers of the form  
\[4^n(8k+7)\]
  cannot be written as the sum of three squares (No Number of Form 4^n(8m+7) Can Be Written as a Sum of Three Squares). Any number congruent to 7 modulo 8 is of this form, and the other possibilies are multiples of such numbers by a power of 4.
\[1004=4 \times 251\]
  and
\[251 \equiv 3 \; (mod \; 8)\]
.
\[1007 \equiv 7 \; (mod \; 8)\]

\[1008=4^2 \times 63\]
  and  
\[63 \equiv 7 \; (mod \; 8)\]

\[1012=4 \times 253\]
  and  
\[253 \equiv 5 \; (mod \; 8)\]

\[1015 \equiv 7 \; (mod \; 8)\]

Hence 1007, 1008 and 1015 cannot be written as the sum of three squares.