11. B5 (CAN 3) (a) Find the rearrangement $\left\{a_{1}, \ldots, a_{n}\right\}$ of $\{1,2, \ldots, n\}$ that maximizes
$$
a_{1} a_{2}+a_{2} a_{3}+\cdots+a_{n} a_{1}=Q .
$$
(b) Find the rearrangement that minimizes $Q$.
11. (a) Suppose $\left\{a_{1}, a_{2}, \ldots, a_{n}\right\}$ is the arrangement that yields the maximal value $Q_{\max }$ of $Q$. Note that the value of $Q$ for the rearrangement $\left\{a_{1}, \ldots, a_{i-1}, a_{j}, a_{j-1}, \ldots, a_{i}, a_{j+1}, \ldots, a_{n}\right\}$ equals $Q_{\max }-\left(a_{i}-\right.$ $\left.a_{j}\right)\left(a_{i-1}-a_{j+1}\right)$, where $1<i<j<n$. Hence $\left(a_{i}-a_{j}\right)\left(a_{i-1}-a_{j+1}\right) \geq 0$ for all $1<i<j<n$.
We may suppose w.l.o.g. that $a_{1}=1$. Let $a_{i}=2$. If $2<i<$ $n$, then $\left(a_{2}-a_{i}\right)\left(a_{1}-a_{i+1}\right)<0$, which is impossible. Therefore $i$ is either 2 or $n$; let w.l.o.g. $a_{n}=2$. Further, if $a_{j}=3$ for $2<j<n$, then $\left(a_{1}-a_{j+1}\right)\left(a_{2}-a_{j}\right)<0$, which is impossible; therefore $a_{2}=3$. Continuing this argument we obtain that $A=\{1,3,5, \ldots, 2[(n-1) / 2]+1,2[n / 2], \ldots, 4,2\}$.
(b) A similar argument leads to the minimizing rearrangement $\{1, n, 2$, $n-1, \ldots,[n / 2]+1\}$.