6 Let $0<p \leqslant a_{i} \leqslant q, b_{i}$ be a permutation of $a_{i}$ $(1 \leqslant i \leqslant n)$, find the extremum of $F=\sum_{i=1}^{n} \frac{a_{i}}{b_{i}}$. (Hungarian Mathematical Olympiad Problem)
6. Let's assume $a_{1} \leqslant a_{2} \leqslant \cdots \leqslant a_{n}$. Since the function is continuous on a closed interval, $F$ has a maximum and minimum value. By the rearrangement inequality, we have $F=\sum_{i=1}^{n} \frac{a_{i}}{b_{i}} \geqslant \sum_{i=1}^{n} \frac{a_{i}}{a_{i}}=\sum_{i=1}^{n} 1=n$, with equality holding when $a_{i}=b_{i}(1 \leqslant i \leqslant n)$, so $F_{\text {min }}=n$. Again, by the rearrangement inequality, we have $F=\sum_{i=1}^{n} \frac{a_{i}}{b_{i}} \leqslant \sum_{i=1}^{n} \frac{a_{i}}{a_{n+1-i}}=F^{\prime}$. Next, we find the maximum value of $F^{\prime}=\sum_{i=1}^{n} \frac{a_{i}}{a_{n+1-i}}$. By symmetry, $2 F^{\prime}=\sum_{i=1}^{n}\left(\frac{a_{i}}{a_{n+1-i}}+\frac{a_{n+1-i}}{a_{i}}\right)$. Since $p \leqslant a_{i} \leqslant q$, we have $\frac{p}{q} \leqslant \frac{a_{i}}{a_{n+1-i}} \leqslant \frac{q}{p}$. The function $f(x)=x+\frac{1}{x}$ is decreasing on $(0,1]$ and increasing on $[1, \infty)$, so $2 F^{\prime}$ can only achieve its maximum when $\frac{a_{i}}{a_{n+1-i}} \in \left\{\frac{p}{q}, \frac{q}{p}\right\}$. When $2 \mid n$, $\frac{a_{i}}{a_{n+1-i}}$ can all take the values $\frac{p}{q}$ or $\frac{q}{p}$, in which case $F_{\max }=\frac{n}{2} \left(\frac{p}{q}+\frac{q}{p}\right)=n+\left[\frac{n}{2}\right]\left(\sqrt{\frac{p}{q}}-\sqrt{\frac{q}{p}}\right)^{2}$. When 2 does not divide $n$, there is always $\frac{a\left[\frac{n}{2}\right]+1}{a_{n+1}-\left(\left[\frac{n}{2}\right]+1\right)}=\frac{a_{\left[\frac{n}{2}\right]+1}}{\left.a_{n-\left[\frac{n}{2}\right]}\right]}=1$, and the other $\frac{a_{i}}{a_{n+1-i}}$ can all take the values $\frac{p}{q}$ or $\frac{q}{p}$. In this case, $F_{\max }=\frac{n-1}{2} \cdot\left(\frac{p}{q}+\frac{q}{p}\right)+1=n+\left[\frac{n}{2}\right]\left(\sqrt{\frac{p}{q}}-\sqrt{\frac{q}{p}}\right)^{2}$. Therefore, the minimum value of $F$ is $n$, and the maximum value is $n+\left[\frac{n}{2}\right]\left(\sqrt{\frac{p}{q}}-\sqrt{\frac{q}{p}}\right)^{2}$.