Let
M(d)=a1a2…an(a1+d)(a2+d)…(an+d).
The key to the proof is to notice that the assumption that M(d) is an integer for every non-negative integer d implies indeed that M(d) is an integer for all integer d: if d<0, consider d′=∣d∣a1…an+d; then, d′≥∣d∣+d≥0 and so, M(d′) is integer. Then, (a1+d′)(a2+d′)…(an+d′)≡0(moda1…an); since d′≡d(moda1…an), we deduce that (a1+d)(a2+d)…(an+d)≡0(moda1…an) and, therefore, M(d) is an integer. We will now show that ak=k for every 1≤k≤n. We proceed inductively. Assuming that ai=i for every i<k, for k≥1, we will show that ak=k. Consider M(−k). By the induction hypothesis, we have that
M(−k)=(k−1)!akak+1…an(−1)k−1(k−1)!(ak−k)(ak+1−k)…(an−k)=akak+1…an(−1)k−1(ak−k)(ak+1−k)…(an−k).
If ak>k, then 0<aj−k<aj for every k≤j≤n, and so, we have that
0<(ak−k)(ak+1−k)…(an−k)<akak+1…an,
which implies that 0<∣M(−k)∣<1. This contradicts the fact that M(−k) is an integer. Therefore, ak=k, which completes the induction.
We conclude that ak=k for every 1≤k≤n. To finish the proof, note that the condition in the statement holds for these values, since for every integer d≥0, we have M(d)=(nn+d), which is integer.