Exercise on Gauss sums Formal count of length-3 progressions, given by:
$A(p)$=#{$(r,s,t): \big(\frac{r}{p}\big)=\big(\frac{s}{p}\big)=\big(\frac{t}{p}\big)=1; r \neq s; s-r\equiv t-s$ (mod $p$). 
Here $p$ is a prime.
In the process of finding $A(p)$ explicitly, there is a step mentioned as follows, which I partially solved, and can't make sure to proceed forward. We could arrive at 
$$A(p)=-\frac{p-1}{2}+\frac{1}{p}\sum_{k=0}^{p-1} \sum_{r,s,t}e^{2 \pi ik(r-2s+t)/p}$$
where $r, s$ and $t$ runs through the quadratic residues. Then it says that using relation
$$\bigg(\frac{a}{p}\bigg)=\frac{c}{\sqrt p} \sum_{j=0}^{p-1}e^{2 \pi iaj^2/p}=\frac{c}{\sqrt p} \sum_{j=0}^{p-1}\bigg(\frac{j}{p}\bigg)e^{2 \pi iaj/p}$$
where $c=1,-i$ as $p \equiv 1,3$ (mod $4$) respectively, we need to prove that 
$$A(p)=\frac{p-1}{8} \bigg(p-6-2 \big( \frac{2}{p} \big)-\big( \frac{-1}{p} \big) \bigg)$$
Throughout, the expressions of the form $\big( \frac{a}{b} \big)$ represents the Legendre's symbol.
I attempted to prove it by writing:
$$A(p)=-\frac{p-1}{2}+\frac{1}{p}\sum_{k=0}^{p-1} \sum_{r,s,t}e^{2 \pi ik(r-2s+t)/p}=-\frac{p-1}{2}+\frac{1}{p}\sum_{k=0}^{p-1} \big(\sum_{r}e^{2 \pi ik(r)/p}\big) \big(\sum_{s}e^{2 \pi ik(-2s)/p}\big) \big( \sum_{t}e^{2 \pi ik(t)/p}\big)$$
and then substituting the relation given. But could not reach the required target. Please help me in proving it.
This problem is attempted to be proved from 'Prime Numbers (A computational perspective)' by Crandall and Pomerance (page 104).
 A: I suspect you may have overlooked the complication in using the given relation: that sum is over all values from $0$ to $p-1$, but the sums you want to simplify are only over quadratic residues.  Or perhaps you did realize this, but made an error in the process of transforming the sum you know into the one you want.  At any rate, let me do that step, and the rest should follow (after some tedious algebra).
We have
$$
\bigg(\frac{a}{p}\bigg)=\frac{c}{\sqrt p} \sum_{j=0}^{p-1}\bigg(\frac{j}{p}\bigg)e^{2 \pi iaj/p}.$$
Breaking this into three parts ($j=0$, $j$ a residue, $j$ a nonresidue), we get
$$
\bigg(\frac{a}{p}\bigg)=\frac{c}{\sqrt p} \bigg(\sum_{j \text{ res}}e^{2 \pi iaj/p} - \sum_{j \text{ nr}}e^{2 \pi iaj/p}\bigg).
$$
Assuming $a\ne 0$, we also have
$$
0=\frac{c}{\sqrt p} \bigg(1+ \sum_{j \text{ res}}e^{2 \pi iaj/p} + \sum_{j \text{ nr}}e^{2 \pi iaj/p}\bigg),
$$
since the sum of all the $p^{\rm{th}}$ roots of unity is zero.  Adding these two, we get
$$
\bigg(\frac{a}{p}\bigg)=\frac{c}{\sqrt p} \bigg(1 + 2\sum_{j \text{ res}}e^{2 \pi iaj/p} \bigg);
$$
thus
$$
\sum_{j \text{ res}}e^{2 \pi iaj/p} = \frac12\bigg({\frac{\sqrt p}{c}\bigg(\frac{a}{p}\bigg) - 1}\bigg)\qquad\text{when }a\ne 0.
$$
Of course,
$$\sum_{j \text{ res}}e^{2 \pi iaj/p} = \frac{p-1}{2}\qquad\text{when }a = 0.$$
Replacing $a$ with $k$, and $j$ with $r$ or $t$, we have
$$
\sum_{r}e^{2 \pi ikr/p} = \sum_{t}e^{2 \pi ikt/p} = \frac12\bigg({\frac{\sqrt p}{c}\bigg(\frac{k}{p}\bigg) - 1}\bigg)
$$
and replacing $a$ with $-2k$, and $j$ with $s$,
$$
\sum_{s}e^{2 \pi i(-2k)s/p} = \frac12\bigg({\frac{\sqrt p}{c}\bigg(\frac{-2}{p}\bigg)\bigg(\frac{k}{p}\bigg) - 1}\bigg),
$$
except all three sums are $(p-1)/2$ when $k = 0$.
Substituting these into your last formula for $k = 0$, a residue or a nonresidue yields a complicated mess, but upon expansion the square roots obligingly cancel out. After noticing that $c^2 = \big(\frac{-1}{p}\big)$, the desired result should appear.
EDIT:  Taking the process one step further by substituting into the formula for $A(p)$ and separating out the $k=0$ case we first get
$$
-\frac{p-1}{2}+\frac{1}{p}\bigg(\frac{p-1}{2}\bigg)^3+\frac{1}{p}\sum_{k=1}^{p-1} \frac18\bigg({\frac{\sqrt p}{c}\bigg(\frac{k}{p}\bigg) - 1}\bigg)^2\bigg({\frac{\sqrt p}{c}\bigg(\frac{-2}{p}\bigg)\bigg(\frac{k}{p}\bigg) - 1}\bigg).
$$
Since $k$ is a quadratic residue $(p-1)/2$ times and a nonresidue equally often, this becomes
$$
-\frac{p-1}{2}+\frac{1}{p}\bigg(\frac{p-1}{2}\bigg)^3+\frac{1}{p}\frac{p-1}{2} \frac18\bigg[\bigg({\frac{\sqrt p}{c} - 1}\bigg)^2\bigg({\frac{\sqrt p}{c}\bigg(\frac{-2}{p}\bigg) - 1}\bigg) + \bigg({-\frac{\sqrt p}{c} - 1}\bigg)^2\bigg({-\frac{\sqrt p}{c}\bigg(\frac{-2}{p}\bigg) - 1}\bigg)\bigg].
$$
