Distance-preserving permutations
The only permutations who satisfy this condition are the identity and its inverse (as string inverse), $\pi(i)=n-i+1$.

Note that $1$ has to be in one of the edges (if it has two neighbors, then at least one of them is bigger  than $2$ and the condition is not satisfied). Placing $1$ in the left edge forces the entire permutation to be the identity, and placing $1$ in the right edge forces the permutation to be its inverse.