We begin by listing all the positive integers from $1$ to $p − 1$: $$1, 2, 3, . . . , p − 1. $$
$p$ is a prime. The numbers on the list that are their own inverse are exactly $1$ and $p − 1$.
For $x, 1\leq x \leq p − 1, x$ is its own inverse if and only if $x^2 ≡ 1 \pmod p$. Because $p$ is prime, this can happen only if $p$ divides either $x − 1$ or $x + 1$.
Then the author writes -
Thus, the numbers on the list that are their own inverse are exactly $1$ and $p − 1$.
I just couldn't see through the last line, how from $p$ divides either $x − 1$ or $x + 1$ we deduce the numbers which are their own inverse are exactly $1$ and $p − 1$?