Arrange all numbers from 1 to n such that no 3 of them are in Arithmetic Progression Is there any possible arrangement of numbers all from $1$ to $n$ such that in the resultant array of numbers, no subsequence of length $3$ is in Arithmetic Progression.
For example, in $1,3,2,4,5$, there is a subsequence of length $3$ that is in AP, that is, $1,3,5.$
But in $1,5,3,2,4$ there is no subsequence of length $3.$
I am trying to find a possible arrangement for larger values of $n,$ but unable to do so.
 A: At least here is some larger solution: $7,11,3,5,1,9,10,2,6,4,12,8$.
A: These exist for all lengths. One quick construction to find arbitrarily large permutations with this property is to go from a length-$n$ permutation $(a_1, a_2, \dots, a_n)$ which has the property to the length-$2n$ permutation $(2a_1, 2a_2,\dots,2a_n, 2a_1-1, 2a_2-1, \dots, 2a_n-1)$. For example, we go from $$(1,2)$$ to $$(2,4,1,3)$$ to $$(4,8,2,6,3,7,1,5)$$ to $$(8,16,4,12,6,14,2,10,7,15,3,11,5,13,1,9)$$ and so on.
(If you want an example with a length that's not a power of $2$, just drop some of the largest terms of one of the permutations.)
To see that this always works, note that an arithmetic progression has the form $(x, \frac{x+y}{2}, y)$; for $\frac{x+y}{2}$ to be an integer, $x$ and $y$ must be both even or both odd. In the construction above, when $x$ and $y$ are both even, they are both in the first half of the bigger permutation; when $x$ and $y$ are both odd, they are both in the second half of the bigger permutation. In either case, they cannot be the endpoints of an arithmetic progression, because then $\lceil \frac x2\rceil$ and $\lceil \frac y2\rceil$ would be the endpoints of an arithmetic progression in $(a_1, a_2, \dots,a_n)$.
But there are many more solutions: see https://oeis.org/A003407 for a count.
A: 
Perl notation: $\quad 1..n\ := \{k\in\mathbb Z: 1\le k\le n\} $

My answer is a relative of @MishaLavrov's answer but it may still provide additional assistance in understanding the given problem which is fo find permutations (or to estimate their number)
$\ f:1..n\rightarrow 1..n\ $ such that $\ f(x)\ $ is never between $\ f(x-d)\ $ and $\ f(x+d)\ $ whenever d $ is an arbitrary integer and a natural number inequality holds
$$ 1\quad \le\quad x-d\ <\ x+d\quad \le\quad n $$
Here is a construction:
let $\ q_k :1..k\rightarrow 1..k\ $ be an arbitrary permutation for arbitrary natural $\ k\in\mathbb N.\ $ The we define a desired permutation $\ f_k: 1..k\rightarrow 1..k\ $ recursively; this permutation $\ f_k\ $ will depend on the permutations $\ q_1 ... q_{k'}\ $ where
$\ k':=\left\lceil \frac k2\right\rceil.\ $ In particular, $\ f_1\ $ is the unique permutation for $\ k:=1.\ $ Then, for $\ k>1,\ $ we let
$$ \forall_{t\,\in\, 1..\left\lceil\frac k2\right\rceil}\quad
 f_k(2\cdot t-1)\,\ :=\,\ q_{\left\lceil\frac k2\right\rceil}(t)\ +
    \ \left\lfloor \frac k2\right\rfloor $$
and
$$\forall_{t\,\in\, 1..\left\lfloor\frac k2\right\rfloor}\quad
 f_k(2\cdot t)\ := f_{\left\lfloor\frac k2\right\rfloor}(t) $$
Permutation $\ f_k\ $ is desired because of each $\ f(x)\ $
is outside of $\ f(x-d)\ $ and $\ f(x+d)\ $ (see above) when these $\ x-d\ $ and $\ x+d\ $ are odd. Otherwise,
$\ x-d\ $ and $\ x+d\ $ must be both even -- but this case is taken care of by the above recursion.



This construction already provides $\ \psi(n)\ $ of different
desired permutations of $\ 1..n,\ $ where
$$ \psi(1) = 1 $$
and
$$ \forall_{n>1}\quad \psi(n)\,\ =
   \,\ \left\lceil\frac n2\right\rceil ! \cdot
   \ \psi\left( \left\lfloor\frac n2\right\rfloor \right) $$
e.g.
$$ \psi(14)\ =\ 7!\cdot 4!\cdot 2! $$



We can do still better. Each step of the recursion we can position the top "half" of the values at the bottom and vice versa. we would need to keep track of our selections during the whole process. Then the number of the desired permutations obtained in this way would be:
$$ \phi(n)\ :=\ 2^{\left\lceil\log_2(n)\right\rceil}
       \cdot \psi(n)\,\ \ge\,\ n\cdot\psi(n) $$

Now I wonder how different is my $\ \phi(n)\ $ from the number of all desired permutations of $\ 1..n$.

