Editorial for DMOPC '21 Contest 5 P2 - Permutations & Primes
Submitting an official solution before solving the problem yourself is a bannable offence.
The problem is essentially asking us to find a permutation of such that the prefix sums are not prime.
Starting with smaller cases of , we have the following outputs:
1 ( is not composite or prime)
1 3 2
For cases where , we can use the fact that the sum of the first natural numbers is , which is composite if . Proof is left as an exercise to the reader. From this, we note that if has a permutation for , then also has a valid permutation, where is just added to the end. This is because the prefix sum at will be .