How should I estimate the following integral
$$I = \int\_0^1 \left( \sum\_{n=0}^{p-1} e(n^2t) \right)^2 dt $$
where $p$ is a prime?


Here is the method I followed:
\begin{align\*}
I & = \int\_0^1 \left( 1+ \sum\_{n=1}^{p-1} e(n^2t) \right)^2 dt \\
& = 1 + 2 \sum\_{n=1}^{p-1} \left( \int\_0^1 e(n^2t) dt \right) + \int\_0^1 \left( \sum\_{n=1}^{p-1} e(n^2t) \right)^2 dt \\
& = 1 + 2 \sum\_{n=1}^{p-1} \left( \frac{e(n^2)-1}{2\pi i n^2} \right) + \int\_0^1 \left( \sum\_{n=1}^{p-1} e(n^2t) \right)^2 dt \\
& = 1+O((p-1)^{1+\epsilon})
\end{align\*}
where the third term is estimated using [Hua's lemma](https://en.wikipedia.org/wiki/Hua%27s_lemma). 


This estimate is not good enough for my purpose. Is it possible to get a better error term than the one here?



Integral over an exponential sum with squares
The integral is equal to exactly one - just expand out the square and use orthogonality to get


$$ I = \sum\_{0\leq n,m<p} \int\_0^1 e((n^2+m^2)t) \mathrm{d} t = \sum\_{0\leq n,m<p}1\_{n^2+m^2=0}=1.$$


