1. Let positive integers $a_{1}, a_{2}, \cdots, a_{31}, b_{1}, b_{2}, \cdots, b_{31}$ satisfy
$$
\begin{array}{l}
\text { (1) } a_{1}<a_{2}<\cdots<a_{31} \leqslant 2015, \\
b_{1}<b_{2}<\cdots<b_{31} \leqslant 2015 ; \\
\text { (2) } a_{1}+a_{2}+\cdots+a_{31}=b_{1}+b_{2}+\cdots+b_{31} \text {. } \\
\text { Find } S=\left|a_{1}-b_{1}\right|+\left|a_{2}-b_{2}\right|+\cdots+\left|a_{31}-b_{31}\right|
\end{array}
$$

the maximum value.
(Supplied by He Yijie)
1. Define the sets
$$
\begin{array}{l}
A=\left\{m \mid a_{m}>b_{m}, 1 \leqslant m \leqslant 31\right\}, \\
B=\left\{n \mid a_{n}<b_{n}, 1 \leqslant n \leqslant 31\right\} . \\
\text { Let } S_{1}=\sum_{m \in A}\left(a_{m}-b_{m}\right), S_{2}=\sum_{m \in B}\left(b_{n}-a_{n}\right) .
\end{array}
$$

Then $S=S_{1}+S_{2}$.
From condition (2), we know
$$
\begin{array}{l}
S_{1}-S_{2}=\sum_{m \in A \cup B}\left(a_{m}-b_{m}\right)=0 \\
\Rightarrow S_{1}=S_{2}=\frac{S}{2} .
\end{array}
$$

When $A=\varnothing, S=2 S_{1}=0$.
Assume $A \neq \varnothing$, then $B \neq \varnothing$. In this case, $|A|, |B|$ are positive integers, and $|A|+|B| \leqslant 31$.
Let $u=a_{k}-b_{k}=\max _{m \in A}\left\{a_{m}-b_{m}\right\}$,
$$
v=b_{l}-a_{l}=\max _{n \in B}\left\{b_{n}-a_{n}\right\} \text {. }
$$

We will prove: $u+v \leqslant 1984$.
Without loss of generality, assume $1 \leqslant k<l \leqslant 31$.
Then $u+v=a_{k}-b_{k}+b_{l}-a_{l}$
$$
=b_{31}-\left(b_{31}-b_{l}\right)-b_{k}-\left(a_{l}-a_{k}\right) \text {. }
$$

From condition (1), we have
$$
\begin{array}{l}
b_{31} \leqslant 2015, b_{31}-b_{l} \geqslant 31-l, \\
b_{k} \geqslant k, a_{l}-a_{k} \geqslant l-k .
\end{array}
$$

Thus, $u+v \leqslant 2015-(31-l)-k-(l-k)$ $=1984$.
Clearly, $S_{1} \leqslant u|A|, S_{2} \leqslant v|B|$, hence,
$$
\begin{array}{l}
1984 \geqslant u+v \geqslant \frac{S_{1}}{|A|}+\frac{S_{2}}{|B|} \geqslant \frac{S_{1}}{|A|}+\frac{S_{2}}{31-|A|} \\
=\frac{S}{2} \cdot \frac{31}{|A|(31-|A|)} \geqslant \frac{31 S}{2 \times 15 \times 16} \\
\Rightarrow S \leqslant \frac{2 \times 15 \times 16}{31} \times 1984=30720 .
\end{array}
$$

On the other hand, if we take
$$
\begin{array}{l}
\left(a_{1}, a_{2}, \cdots, a_{16}, a_{17}, a_{18}, \cdots, a_{31}\right) \\
=(1,2, \cdots, 16,2001,2002, \cdots, 2015), \\
\left(b_{1}, b_{2}, \cdots, b_{31}\right)=(961,962, \cdots, 991),
\end{array}
$$

then conditions (1) and (2) are both satisfied. In this case,
$$
S=2 S_{1}=2 \times 16 \times 960=30720 \text {. }
$$

In conclusion, the maximum value of $S$ is 30720.