For example,
$n = 3$, $(2,3,1,2,1,3)$ or $(3,1,2,1,3,2)$
$n = 4$, $(4,1,3,1,2,4,3,2)$ or $(2,3,4,2,1,3,1,4)$
This problem does have a name, but I did not find it. Thanks for @Martin R, It is called Langford pairing problem.
Assume that $L_{n}$ is the number of solutions of Langford pairing problem.
Actually, I want to know some conclusions or references about the following:
The proof of $L_{n} = 0~~\text{iff}~~n~\text{mod}~4 = 1~\text{or}~2$.
The general formula or recurrence formula of $L_{n}$ (A176127$(n)$ in OEIS).
Given $n$, how to find one of the solutions.
Given $n$, how to find all the solutions and the representation of them.
As for (1), it is proved in "Some new possibilities of optimum synthetic linear arrays for radioastronomy" in 1975. You are welcome if you have a simple proof.
As for (2)(4), the answer seems open.
As for (3), I have no idea about the algorithm.
Assume that $A_{m,n} = (1,2,\ldots,n,1,2,\ldots,n, \ldots, 1,2, \ldots, n)$ (repeat $m$ times). There is a concept named high-order sequence denoted $L(m,n)$. It is denoted the number of permutations of $A_{m,n}$ with the property that there are $k$ numbers between each two $k$'s in the set for $k=1,\ldots,n$.
I will close this question unless it is useful.