7. (1999 National High School Competition Question) Given a positive integer $n$ and a positive number $M$, for all arithmetic sequences $a_{1}, a_{2}, a_{3}, \cdots$ satisfying the condition $a_{1}^{2}+a_{n+1}^{2} \leqslant M$, find the maximum value of $S=a_{n+1}+a_{n+2}+\cdots+a_{2 n+1}$.
7. Let the common difference be $d$, then $a_{2 n+1}=a_{1}+2 n d=2\left(a_{1}+n d\right)-a_{1}=2 a_{n+1}-d$, and $S=a_{n+1}+a_{n+2}+\cdots+a_{2 n+1}=$ $\frac{\left(a_{n+1}+a_{2 n+1}\right)(n+1)}{2}=\frac{\left(3 a_{n+1}-a_{1}\right)(n+1)}{2}$. By the Cauchy-Schwarz inequality, we have $\left(3 a_{n+1}-a_{1}\right)^{2} \leqslant\left(3^{2}+1^{2}\right)\left[a_{n+1}^{2}+\right.$ $\left.\left(-a_{1}\right)^{2}\right] \leqslant 10 M$, so $S \leqslant \frac{1}{2}(n+1) \sqrt{10 M}$. Equality holds if and only if $\frac{a_{n+1}}{3}=\frac{-a_{1}}{1}>0$ and $a_{1}^{2}+a_{n+1}^{2}=M$, i.e., when $a_{1}=-\frac{\sqrt{10 M}}{10}, a_{n+1}=\frac{3 \sqrt{10 M}}{10}$, $S$ reaches its maximum value $\frac{1}{2}(n+1) \sqrt{10 M}$.