Solution:
Let us denote by Fn the number of elements of the set An. We have F1=1,F2=2 and F3=6. For n>3, consider any permutation (a1,a2,…,an) in An. Since n−1 divides 2(a1+⋯+an−1)=n(n+1)−2an≡2−2an(modn−1), it follows that an equals 1,2n+1 or n.
Suppose that an=2n+1. Then n−2 divides 2(a1+⋯+an−2)=n2−1−2an−1≡3−2an−1(modn−2). Hence we must have 2an−1−3=n−2, but then an−1=2n+1=an, a contradiction.
If an=n, then (a1,…,an)→(a1,…,an−1) is a bijective mapping onto the set An−1, so there are Fn−1 such permutations.
If an=1, then (a1−1,…,an−1−1) is a permutation of {1,…,n−1} which belongs to the set An−1, since 2((a1−1)+⋯+(ak−1))=2(a1+⋯+ak)−2k is divisible by k for 1⩽k⩽n−1. As in the previous case, there are Fn−1 such permutations.
We conclude that Fn=2Fn−1 for n>3, which together with F3=6 gives Fn=3⋅2n−2 for n⩾3.