Given the vertices $A_{1} A_{2} \ldots A_{n}$ of a regular $n$-gon, we write the numbers $1,2, \ldots, n$ on them in some order. 

a) What is the maximum possible value of the sum of the absolute differences of adjacent numbers?

b) How many different arrangements can achieve this maximum sum?
a) Let the number written to vertex $A_{j}$ be $a_{j}$, and let $b_{j}=\max \left(a_{j+1}, a_{j}\right)$ and $c_{j}=\min \left(a_{j+1}, a_{j}\right)$. Then, with the agreement that $\left(a_{n+1}=a_{1}\right)$:

$$
\sum_{j=1}^{n}\left|a_{j+1}-a_{j}\right|=\sum_{j=1}^{n} b_{j}-\sum_{j=1}^{n} c_{j}
$$

Among the numbers $b_{1}, b_{2}, \ldots, b_{n}, c_{1}, c_{2}, \ldots, c_{n}$, each of the numbers $1,2, \ldots, n$ appears exactly twice.

Therefore, for even $n$:

$$
\sum_{j=1}^{n} b_{j} \leq 2\left[\left(\frac{n}{2}+1\right)+\left(\frac{n}{2}+2\right)+\cdots+n\right]
$$

and

$$
\sum_{j=1}^{n} c_{j} \geq 2\left[1+2+\cdots+\frac{n}{2}\right]
$$

Thus,

$$
\begin{gathered}
\sum_{j=1}^{n} b_{j}-\sum_{j=1}^{n} c_{j} \leq 2\left[\left(\frac{n}{2}+1\right)+\left(\frac{n}{2}+2\right)+\cdots+n\right]-2\left[1+2+\cdots+\frac{n}{2}\right]= \\
=2 \cdot \frac{1}{2} \cdot \frac{n}{2} \cdot\left(\frac{n}{2}+1+n\right)-2 \cdot \frac{1}{2} \cdot \frac{n}{2} \cdot\left(1+\frac{n}{2}\right)=\frac{n^{2}}{2}
\end{gathered}
$$

Similarly, for odd $n$:

$$
\begin{aligned}
\sum_{j=1}^{n} b_{j}-\sum_{j=1}^{n} c_{j} \leq\left(2\left[\frac{n+1}{2}+1+\frac{n+1}{2}+2+\cdots+n\right]+\frac{n+1}{2}\right) & - \\
& -\left(2\left[1+2+\cdots+\frac{n+1}{2}-1\right]+\frac{n+1}{2}\right)=\frac{n^{2}-1}{2}
\end{aligned}
$$

We will show that equality can hold in both cases.

In the first case, it is sufficient to write the numbers on the circle in the order $1, \frac{n}{2}+1,2, \frac{n}{2}+2, \ldots, \frac{n}{2}, n$, and in the second case, the order $1, \frac{n+3}{2}, 2, \frac{n+5}{2}, \ldots, \frac{n-1}{2}, n, \frac{n+1}{2}$ is suitable.

b) If $n$ is even, we get the maximum sum if the numbers not greater than $\frac{n}{2}$ and the numbers greater than $\frac{n}{2}$ alternate: in the sum $\sum_{j=1}^{n} b_{j}-\sum_{j=1}^{n} c_{j}$, every number greater than $\frac{n}{2}$ then appears with a coefficient of +2, and every number not greater than $\frac{n}{2}$ with a coefficient of -2. The number of possibilities is therefore:

$$
n \cdot \frac{n}{2}\left(\frac{n}{2}-1\right)\left(\frac{n}{2}-1\right)\left(\frac{n}{2}-2\right)\left(\frac{n}{2}-2\right) \ldots 1 \cdot 1=2\left(\left(\frac{n}{2}\right)!\right)^{2}
$$

indeed, there are $n$ possibilities for the number at $A_{1}$, then $\frac{n}{2}$ for the number at $A_{2}$, $\frac{n}{2}-1$ for the number at $A_{3}$, and so on.

If $n$ is odd, we calculate a little differently. The equality $\sum_{j=1}^{n} b_{j}-\sum_{j=1}^{n} c_{j}=\frac{n^{2}-1}{n}$ holds if in the arrangement, every number less than $\frac{n+1}{2}$ has a neighbor greater than $\frac{n+1}{2}$ and vice versa, and furthermore, one of the neighbors of $\frac{n+1}{2}$ is greater and the other is less than $\frac{n+1}{2}$. Thus, the number of suitable arrangements is $2 n\left[\left(\frac{n-1}{2}\right)!\right]^{2}$; indeed, there are $n$ possibilities for the placement of $\frac{n+1}{2}$, then $n-1$ for the next one, and then $\frac{n-1}{2}, \frac{n-1}{2}-1, \frac{n-1}{2}-1, \frac{n-1}{2}-2, \frac{n-1}{2}-2, \ldots, 1,1$ for the number of possibilities.

Based on the work of Zoltán Gyenes (Budapest, ELTE Apáczai Csere J. Gymnasium, 10th grade)