TITLE: What's the name of this quantity?
QUESTION [10 upvotes]: For each permutation $\sigma$ of $ \left\{ 1, 2, \dots, n \right\}$ define 
$$\operatorname{dist}(\sigma)=\sum_{i=1}^{n}\left| \sigma (i)-i \right|$$ 
For each $n\in\mathbb{N}$, I'm interested in finding the maximum value this function can score, namely
$$M_n=\max_{\sigma\in D_n}\left\{\operatorname{dist}(\sigma)\right\}$$
Does $M_n$ has a conventional name? Uses? Is there a formula to find it?
I've noticed that $M_n$ grows "in pairs", meaning that for each odd $a\in \mathbb{N}$ it holds that $$M_{a+1}-M_a=M_{a+2}-M_{a+1}$$
I guess it can represent some kind of measure for hardness to sort.

REPLY [3 votes]: Let $n=2m$. Take any permutation where if $n\leq m$ then $\sigma(n)>m$ and if $n>m$ then $\sigma(n)\leq m$. Then $\sum_{(k=i)}^m|\sigma(m)-i|=\sum_{(k=i)}^m\sigma(m)-i=m^2$ and $\sum_{(i=m+1)}^{2m}|\sigma(m)-i|=\sum_{(i=m+1)}^{2m}i-\sigma(m)=m^2$.
Now suppose you have a permutation that does not satisfy this. Then it has a pair $i,j$ where $i,\sigma(i)\leq m$ and $j,(\sigma(j)>m$. Show switch $\sigma(i)$ and $\sigma (j)$ makes the distance sum larger.
Do the same for the other side to get:
For $n=2m+1$ this is $m(2m+2)$. For $n=2m$ this is $2m^2$

For a geometrical interpretation See that if $\sigma(m)$ and $(m)$ and $\sigma(j)$ and $j$ are on different sides then the distance between them is more than $DE+FG$