The result is trivial when , so assume "p" is an odd prime, . Since the residue classes (mod "p") are a field, every non-zero "a" has a unique multiplicative inverse, "a"−1. Lagrange's theorem implies that the only values of "a" for which are (because the congruence can have at most two roots (mod "p")). Therefore, with the exception of ±1, the factors of can be arranged in unequal pairs, where the product of each pair is . This proves Wilson's theorem.