If $S = \left\{x \in \mathbb{R} : \sin^{-1}\left(\frac{x+1}{\sqrt{x^{2}+2x+2}}\right) - \sin^{-1}\left(\frac{x}{\sqrt{x^{2}+1}}\right) = \frac{\pi}{4}\right\}$ then $\sum_{x \in S}\left(\sin\left((x^{2}+x+5)\frac{\pi}{2}\right) - \cos\left((x^{2}+x+5)\pi\right)\right)$ is equal to ______.
Numerical-value question: the answer is a number.
Show answer
The answer is 4.
Key from source paper