For some positive integers n it is possible to rearrange the sequence $1,2,3, ... , n$, $1,2,3, ... , n$ so that for each $m = 1,2, ... n $ there are exactly $m$ other terms between the two copies of m. For $n = 3$, an example is $3,1,2,1,3,2$. For $n = 4$, an example is $4,1,3,1,2,4,3,2.$ On the other hand, this cannot be done for $n = 5.$ Determine with proof whether such a rearrangement exists for $n = 2018.$
What I have tried is to “build up" from cases: I discovered that n=2 is impossible but I can't get anywhere from building up. Then I tried a "space taking" argument-- because there are $m$ other terms between two copies of $m$, I tried to add up$1+2+3+...n$= $n(n+1)/2$ but I discovered that the space taken up could be shared... Some suggestion of how to solve this will be appreciated.
HINT
If you add up the distances between the pairs of identical numbers in the original sequence, you get $n\cdot (n-1)$. Now, as you shuffle the elements around, what will happen to the parity of that? And how does that compare to the parity of the sum of distances in the goal sequence (which is indeed $\frac{n(n+1)}{2})$?