Solution: It is possible if and only if n is odd.
If n is even, then a1+a2+⋯+an=1+2+⋯+n=2n⋅(n+1), which is congruent to 0 mod n+1. Therefore, the task is impossible.
Now suppose n is odd. We will show that we can construct a1,a2,…,an that satisfy the conditions given in the problem. Then let n=2k+1 for some non-negative integer k. Consider the sequence: 1,2k,3,2k−2,5,2k−3,…,2,2k+1, i.e. for each 1≤i≤2k+1, ai=i if i is odd and ai=2k+2−i if i is even.
We first show that each term 1,2,…,2k+1 appears exactly once. Clearly, there are 2k+1 terms. For each odd number m in {1,2,…,2k+1}, am=m. For each even number m in this set, a2k+2−m=2k+2−(2k+2−m)=m. Hence, every number appears in a1,…,a2k+1. Hence, a1,…,a2k+1 does consist of the numbers 1,2,…,2k+1 in some order.
We now determine a1+a2+⋯+am(mod2k+2). We will consider the cases when m is odd and when m is even separately. Let bm=a1+a2+⋯+am.
If m is odd, note that a1≡1(mod2k+2), a2+a3=a4+a5=⋯=a2k+a2k+1=2k+3≡1(mod2k+2). Therefore, {b1,b3,…,b2k+1}={1,2,3,…,k+1}(mod2k+2).
If m is even, note that a1+a2=a3+a4=⋯=a2k−1+a2k=2k+1≡−1(mod2k+2). Therefore, {b2,b4,…,b2k}={−1,−2,…,−k}(mod2k+2)≡{2k+1,2k,…,k+2}(mod2k+2).
Therefore, b1,b2,…,b2k+1 do indeed have different remainders when divided by 2k+2. This completes the problem. □