By the Chinese remainder Theorem, for every k=2,3,…,n there exists bk so that
bk≡0(mod(k−1)),bk≡k(modn).
Let a1=1 and for k=2,…,n, ak is the remainder when bk/(k−1) is divided by n. Since bn≡0(modn), we have an=0. Also if ai=aj, then bi/(i−1)≡bj/(j−1)(modn), i.e., i(j−1)≡j(i−1)(modn). Since n is prime, i=j. Thus a1,…,an are distinct. Now
a1a2…ak≡(k−1)!b2…bk≡k(modn).