# A mentally handicapped problem

Algebra Level 5

Let $$a_1,a_2,\ldots, a_{31}$$ and $$b_1,b_2, \ldots, b_{31}$$ be positive integers such that $$a_1< a_2<\cdots< a_{31} \leq 2015$$; $$\ b_1< b_2<\ldots<b_{31} \leq 2015 \$$ and $$\ a_1+a_2+\cdots+a_{31}=b_1+b_2+\cdots+b_{31}$$.

Find the maximum value of

$S=|a_1-b_1|+|a_2-b_2|+\cdots+|a_{31}-b_{31}|.$

×