41. Let $a \bmod n$ denote the remainder of $a$ divided by $n$ (i.e., $\left.a-\left[\frac{a}{n}\right] \cdot n\right)$. For given $m, n \in \mathbf{N}^{*}$, find $\max _{0 \leqslant a_{1}, a_{2}, \cdots, a_{m}<n} \min _{0 \leqslant k<n} \sum_{j=1}^{m}\left(\left(a_{j}+k\right) \bmod n\right)$, where $a_{1}$, $a_{2}, \cdots, a_{m} \in \mathbf{Z}$
41. The answer is: $\frac{1}{2}((m-1)(n-1)+(m, n)-1)$.

Because
$$a_{j}+k(\bmod n)=\left\{\begin{array}{l}
a_{j}+k, a_{j}<n-k \\
a_{j}+k-n, a_{j} \geqslant n-k
\end{array}\right.$$

Hence
$$\begin{aligned}
S & =\sum_{j=1}^{m}\left(\left(a_{j}+k\right) \bmod n\right) \\
& =\sum_{j=1}^{m} a_{j}+m k-\left(\mu_{n-1}+\mu_{n-2}+\cdots+\mu_{n-k}\right) \cdot n
\end{aligned}$$

where $\mu_{i}$ is the number of times $i$ appears in $a_{1}, a_{2}, \cdots, a_{n}$.
From (9), the minimum value of $S$ is achieved when $k=0$ if and only if
$$\mu_{n-1}+\mu_{n-2}+\cdots+\mu_{n-k} \leqslant\left[\frac{m k}{n}\right], 1 \leqslant k \leqslant n-1$$

Notice that, if the minimum value of $S$ is achieved at $0 \leqslant l \leqslant n-1$, let $b_{j} \equiv a_{i}+l(\bmod n)$, then the minimum value of $S$ for $b_{1}, b_{2}, \cdots, b_{n}$ (all $\in\{0,1, \cdots, n-1\}$) is also achieved at $k=0$. Therefore, we can assume that the minimum value of $S$ is achieved at $k=0$. In this case, (10) holds, and $S_{\min }=\sum_{j=1}^{m} a_{j}$.

Next, we find the maximum value of $\sum_{j=1}^{m} a_{j}$ under condition (10). Since
$$\sum_{j=1}^{m} a_{j}=\sum_{i=1}^{n-1}(n-i) \mu_{n-i}$$

it is equivalent to finding the maximum value of $T=\sum_{i=1}^{n-1}(n-i) \mu_{n-i}$ under conditions (10) and $\sum_{i=1}^{n} \mu_{n-i}=m$.

For $1 \leqslant k \leqslant n$, let
$$\bar{\mu}_{n-k}=\left[\frac{m k}{n}\right]-\left[\frac{m(k-1)}{n}\right]$$

Then $\sum_{i=1}^{n} \bar{\mu}_{n-i}=m$, and the sequence $\left(\bar{\mu}_{0}, \bar{\mu}_{1}, \cdots, \bar{\mu}_{n-1}\right)$ satisfies (10), and
$$\sum_{i=1}^{k} \mu_{n-i} \leqslant\left[\frac{m k}{n}\right]=\sum_{i=1}^{k} \bar{\mu}_{n-i}$$

Thus
$$\begin{aligned}
T & =\sum_{i=1}^{n-1}(n-i) \mu_{n-i}=\sum_{k=1}^{n-1} \sum_{i=1}^{k} \mu_{n-k} \leqslant \sum_{k=1}^{n-1} \sum_{i=1}^{k} \bar{\mu}_{n-i} \\
& =\sum_{i=1}^{n-1}(n-i) \bar{\mu}_{n-i}
\end{aligned}$$

Therefore
$$T_{\max }=\sum_{i=1}^{n-1}(n-i) \bar{\mu}_{n-i}=\sum_{k=1}^{n-1}\left[\frac{m k}{n}\right]=\frac{1}{2}((m-1)(n-1)+(m, n)-1)$$

The last equation uses the result from Example 1 in Section 5.2.