Question 23
The squad leader sees that Old Zhao is so bored during his military service that he sends him to arrange steamed buns. There are $n$ different colours of steamed buns; there are $a_i$ buns of the $i$-th colour, $S = a_1 + a_2 + \cdots + a_n$ buns in total. These $S$ buns are pairwise distinct. Old Zhao may now decide how to arrange these $S$ buns in a row. For each arrangement, the squad leader scores Old Zhao as follows:
(i) First, for each $i \in \{1, 2, \cdots, n\}$, count the number of adjacencies of buns of the $i$-th colour, that is
$$
c_i = \#\{j: 1 \le j \le S-1, \text{ the } j\text{-th and } (j+1)\text{-th buns from the left are both of colour } i\}
$$
(ii) Old Zhao's score is defined as $c_1 \times c_2 \times \cdots \times c_n$.
If $S$ is composite, prove that the sum of the scores of all arrangements is a multiple of $S$.
(i) First, for each $i \in \{1, 2, \cdots, n\}$, count the number of adjacencies of buns of the $i$-th colour, that is
$$
c_i = \#\{j: 1 \le j \le S-1, \text{ the } j\text{-th and } (j+1)\text{-th buns from the left are both of colour } i\}
$$
(ii) Old Zhao's score is defined as $c_1 \times c_2 \times \cdots \times c_n$.
If $S$ is composite, prove that the sum of the scores of all arrangements is a multiple of $S$.