Suppose that $a,p$ are nonnegative integers such that $p$ is prime and $p\nmid (a-1)$. If $(a-1)^{p+1}+a^p=(a+1)^{p-1}$, find the sum of all possible values of $a$.
We can't have $p = 2$ since the equation $$(a-1)^3+a^2 = (a+1)$$ has no integer solutions. We now take two cases:
Case 1: $p \mid (a+1)$
In this case, $a \equiv -1 \pmod{p}$. Then $(a-1)^{p+1} \equiv (-2)^{p+1} \equiv 4 \equiv -a^p \equiv -a \pmod{p}$. Thus $a \equiv 4 \pmod{p}$ and therefore $p \mid 3$, so that $p = 3$. Thus $a = 2$ in this case.
Case 2: $p \nmid (a+1)$
We have $$(a-1)^{p+1}+a^p \equiv (a-1)^2+a^p \equiv 1 \pmod{p}.$$ If $a \not \equiv 0 \pmod{p}$, then we have $(a-1)^2+a \equiv 1 \pmod{p}$, which gives $a(a-1) \equiv 0 \pmod{p}$. Thus $p \mid (a-1)$, a contradiction. Thus $a \equiv 0 \pmod{p}$.
How do I continue from here?