TITLE: pigeonhole principle 
QUESTION [5 upvotes]: Hi everyone 
I saw a question on Mathoverflow asking for some applications of pigeonhole principle, among the answers I saw a problem set which was proposed by Prof. Richard Stanley and in this problem set there was a question which I am interested on it,  here it is: 
Consider these two sequences $a_1< a_2 < \cdots < a_n$ and  $b_1 >b_2 > \cdots >b_n$ such that $$\{a_1,\cdots a_n,b_1\cdots b_n\}=\{1,2,\cdots 2n\}$$ show that 
$$\sum_i|a_i-b_i|=n^2$$
I have no idea how to do this. Perhaps someone can give a hint? I try to consider some cases but the answer was long and boring, I think there is a nice trick.

REPLY [12 votes]: Consider the sum $S = \sum (a_i + b_i ) + \sum |a_i - b_i|$. The first term evaluates to $n(2n+1)$. The second term is unknown. Claim: $S$ is equivalent to $2\sum_{n+1}^{2n} i = n(3n+1)$ which implies the result you want. 
It is easy to see that $S$ is equivalent to twice the sum of $\sum \max(a_i,b_i)$. Using the pigeonhole principle you can show that $\max(a_i,b_i) > n$.

REPLY [4 votes]: I'll expand slightly on Dan's suggestion.
Any such pair of sequences $(\{a_{i}\}, \{b_{j}\})$ can be obtained from the pair of sequences $(\{i\}, \{2n+1-j\})$ by finitely many iterations of the following operation.
For some $i$ and some $j$ with $a_{i} = k, b_{j} = k+1$, set $a_{i} = k+1, b_{j} = k$.
Now just check that the claim holds for the pair of sequences $(\{i\}, \{2n+1-j\})$, and that the operation I described leaves the sum invariant.