Problem

Source: Russian TST 2017, Day 7 P3 (Group NG)

Tags: number theory, residue



Let $a_1,\ldots , a_{p-2}{}$ be nonzero residues modulo an odd prime $p{}$. For every $d\mid p - 1$ there are at least $\lfloor(p - 2)/d\rfloor$ indices $i{}$ for which $p{}$ does not divide $a_i^d-1$. Prove that the product of some of $a_1,\ldots , a_{p-2}$ gives the remainder two modulo $p{}$.