Solution (source code)

= Solution

For $n\geq1$, the zero <residue> contributes zero. Write $S=\sum_{x\in\mathbb F_p^\times}x^n$. Multiplication by any nonzero $\alpha$ permutes these residues, so $S=\alpha^nS$ in $\mathbb F_p$. If $(p-1)\nmid n$, choose a <primitive root> $g$; then $g^n\neq1$, and $(1-g^n)S=0$ forces $S=0$.

If $(p-1)\mid n$, every nonzero $x$ has $x^n=1$, so $S=p-1\equiv-1\pmod p$. Therefore
$$
\boxed{\sum_{x=1}^p x^n\equiv
\begin{cases}0,&(p-1)\nmid n,\\-1,&(p-1)\mid n\end{cases}\pmod p\quad(n\geq1).}
$$
The source also lists $n=0$, although its premise assumes $n\geq1$. For that separate case, the <integer> sum has $p$ terms each equal to one, so it is zero modulo $p$.