If $A=\left\{a_{1}, a_{2}, \ldots, a_{p}\right\}$ is complete system of residue then $\sum_{1\leq i < j \leq p}a_ia_j \equiv 0 (\text{mod p})$. Let $A=\left\{a_{1}, a_{2}, \ldots, a_{p}\right\}$ be a complete system of residues modulo a prime number $p \geq 5 .$ and $$ N_p = \sum_{1\leq i < j \leq p}a_ia_j.$$  Show $N_p \equiv 0 \text{(mod p)}$.
Showing that $N_pA$ (the left coset) is not a complete system seems to be the best way but I can't seem to work it out. Please provide hint.
 A: The natural way to approach such problems is to reduce modulo $p$. The claim that the sequence $m \in \mathbb{Z}^p$ is a complete system of residues means that the map:
$$\begin{align*}  
[1, p] &\to \mathbb{Z}_p\\
k &\mapsto \overline{m_k}
\end{align*}$$
is surjective, where by $[m, n]$ I am referring to the integer interval between $m$ and $n$, $\mathbb{Z}_r\colon=\mathbb{Z}/r\mathbb{Z}$ denotes the quotient ring of residue classes and the overbar refers to taking the residue class modulo $p$. Since both sets $[1, p]$ and $\mathbb{Z}_p$ are of cardinality $p$, any surjection between them must necessarily be an injection as well.
Consider now the polynomial $X^p-X \in \mathbb{Z}_p[X]$. By Lagrange's theorem, any $x \in \mathbb{Z}_p^{\times}$ satisfies $x^{p-1}=\overline{1}$ hence also $x^p=x$, relation which is also trivially satisfied by $x=\overline{0}$. This means that $X-x|\ X^p-X$ for every $x \in \mathbb{Z}_p$ and since two polynomials of first degree and with distinct roots are always relatively prime, it follows that $\displaystyle\prod_{x \in \mathbb{Z}_p}(X-x)|\ X^p-X$. Since the product on the left-hand side has the same degree $p$ as the polynomial on the right hand-side, it follows that $X^p-X=a\displaystyle\prod_{x \in \mathbb{Z}_p}(X-x)$ for a nonzero constant $a \in \mathbb{Z}_p^{\times}$, constant which is determined to be $a=\overline{1}$ by comparing dominant coefficients (the conclusion follows immediately since both polynomials in question are monic).
By virtue of the injectivity argued in the first paragraph we have the decomposition $X^p-X=\displaystyle\prod_{x \in \mathbb{Z}_p}(X-x)=\displaystyle\prod_{1 \leqslant k \leqslant p}(X-\overline{m_k})$. We recall Vieté's relations, according to which the coefficient of degree $p-2$ of this polynomial is given by:
$$s\colon=\sum_{1 \leqslant k<l\leqslant p}\overline{m_km_l}.$$
However, under the hypothesis $p \geqslant 5$ (which entails $p-2 \notin \{1, p\}$) the polynomial $X^p-X$ has no term of degree $p-2$, whence the conclusion.
A: Modulo $p$, this is equal to the sum of all products of distinct residues. We can rewrite the sum as
$$
\begin{align}
N_p &\equiv \sum_{0 \leq i < j \leq p-1} ij \equiv \sum_{i=2}^{p-1} i\cdot\left(\sum_{j=1}^{i-1} j\right) \equiv \sum_{i=2}^{p-1} i\cdot \frac{i(i-1)}{2}
\\ & \equiv \frac 12 \sum_{i=2}^{p-1}i^2(i-1) 
\equiv \frac 12 \left(\sum_{i=2}^{p-1}i^3 - \sum_{i=2}^{p-1}i^2 \right)
\\ & \equiv
\frac 12 \left(\sum_{i=1}^{p-1}i^3 - \sum_{i=1}^{p-1}i^2 \right).
\end{align}
$$
With the formulas
$$
\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}, \quad 
\sum_{i=1}^n i^3 = \left[\frac{n(n+1)}{2}\right]^2,
$$
we see that both of these sums are equal to $0$ modulo $p$. Thus, $N_p \equiv 0$ modulo $p$, as desired.
