On the property of Gauss sum In the book of a classical introduction to modern number theory by Kenneth Ireland and Michael Rosen page 92
in the proof of proposition 8.2.2 of gauss sum, I don't understand how he gets this
$ \sum_{x} \sum_{y} \chi(x) \bar{\chi(y)} \delta(x,y)p =p(p-1)$
Where $\delta(x, y)$ is one if $x\equiv y \pmod p$ and zero otherwise , x, y $\in$ $\mathbb{F}_{p}$ , and $\chi $ is dirichlet character mod $p $.
 A: Divide both sides of the equation
$$ \sum_x \sum_y \chi(x) \overline{\chi(y)} \delta(x,y)p = p(p-1) \tag{1} $$
by $\,p\,$ to get
$$ \sum_x \sum_y \chi(x) \overline{\chi(y)} \delta(x,y)  = (p-1). \tag{2} $$
The double sum in this new equation is essentially the trace of a matrix.
More precisely, if $\,A:=\{A_{i,j}\}\,$ is any matrix, then by definition,
its trace
$$ \text{tr}(A) := \sum_i A_{i,i} = \sum_i \sum_j A_{i,j}\delta_{ij} \tag{3} $$
can be written either as a single sum or else, using the
Kronecker delta,
as an equivalent double sum. The
same holds for equation $(2)$.

An alternative method is the following
$$ \sum_y \chi(x) \overline{\chi(y)} \delta(x,y)\,p
 = \chi(x) \overline{\chi(x)} \,p
 = \sum_y |\chi(x)|^2\ \tag{4} $$
where the first sum is equivalent to a single value since only
terms with $\,y=x\,$ are non-zero.
Equation $(1)$ can now be rewritten as
$$ S:=\sum_x \sum_y \chi(x) \overline{\chi(y)} \delta(x,y)p =
  \sum_x \sum_y |\chi(x)|^2\ = \sum_y\left(\sum_x |\chi(x)|^2\right). \tag{5}$$
Now, by definition of $\,\chi\,$ we have $\,|\chi(x)|^2=1\,$ iff $\,x\ne 0,\,$
or written another way, $\,|\chi(x)|^2 = 1 - \delta(x,0).\,$ Thus we have
$$ S = \sum_y \left(\sum_x 1-\delta(x,0)\right) = p(p-1) \tag{6} $$
where the right side is $\,p(p-1)\,$ because $\,1-\delta(x,0)\,$ is $1$
iff $\,x\ne 1\,$ and there are exactly $\,p(p-1)\,$ such pairs $\,(y,x).$
