Proof that a Gauss sum associated with a quadratic character mod p is the same as a quadratic Gauss sum

In this note I want to quickly record a solution I have found to the following problem: If p is an odd prime such that p \nmid n and \chi(r) = (r|p), prove that

G(n, \chi) = \sum_{r \text{mod } p} (r|p) e^{2 \pi i n r/p} = \sum_{r = 1}^p e^{2 \pi i n r^2/p} = G(n ; p)

My solution is as follows. We have

G(n, \chi) = \sum_{r \text{mod } p} (r|p) e^{2 \pi i n r/p}

= \sum_{\substack{\text{quadratic}\\\text{residues }r}} e^{2 \pi i n r/p} - \sum_{\substack{\text{quadratic}\\\text{non-residues }s}} e^{2 \pi i n s/p}

whereas

G(n ; p) = \sum_{r = 1}^p e^{2 \pi i n r^2/p}

= \sum_{r = 1}^{p-1} e^{2 \pi i n r^2/p} + 1

= 2\sum_{\substack{\text{quadratic}\\\text{residues }r}} e^{2 \pi i n r/p} + 1

(since r mod p will range over both quadratic residues and non-residues, so r^2 will range over the quadratic residues twice)

= \sum_{\substack{\text{quadratic}\\\text{residues }r}} e^{2 \pi i n r/p}

+ \big \{ \sum_{\substack{\text{quadratic}\\ \text{residues }r}} e^{2 \pi i n r/p} + 1 \big \}

Therefore G(n, \chi) = G(n ;  p) if and only if

- \sum_{\substack{\text{quadratic}\\\text{non-residues }s}} e^{2 \pi i n s/p}

= \sum_{\substack{\text{quadratic}\\ \text{residues }r}} e^{2 \pi i n r/p} + 1

\iff

\sum_{\substack{\text{quadratic}\\ \text{residues }r}} e^{2 \pi i n r/p} + \sum_{\substack{\text{quadratic}\\ \text{non-residues }s}} e^{2 \pi i n s/p} = -1

But this is true because

\sum_{\substack{\text{quadratic}\\ \text{residues }r}} e^{2 \pi i n r/p} + \sum_{\substack{\text{quadratic}\\ \text{non-residues }s}} e^{2 \pi i n s/p} = \sum_{r=1}^{p-1} e^{2 \pi inr/p}

This is a geometric sum of the form

S = \sum_{r=1}^{p-1} x^r = x + x^2 + \cdots + x^{p-1}

where

x = e^{2 \pi in/p}

Therefore

xS = x^2 + x^3 + \cdots + x^p

Subtracting the expression for S from this we get

(x - 1)S = x^p - x = 1 - x

(the last equality is true because x is a p-th root of unity)

\iff

S = -1

Therefore G(n, \chi) = G(n ; p).