How prove this nice inequality
Firstly, $\dfrac {n}{2\sqrt{n-1}}$ is an increasing function and $\geq 1$ for $n\geq 2$.
Let's prove by induction:
For $n=2$, it's obvious.
Assume it holds for $1,2,...,k-1$.
For $n=k;$
If $max(a_1,a_2,\cdots,a_n)=a_t$ where $t\gt1$, then because $min(a_i,a_{i+1},\cdots,a_t,\cdots,a_n)\leq min(a_i,a_{i+1},\cdots,a_{t-1})$ for all $i\leq t-1$, and $max(a_1,a_2,\cdots,a_j)=max(a_t,a_{t+1},\cdots,a_j)$ for all $j\geq t$,
$$\sum_{i=1}^{n}\max({a_{1},a_{2},\cdots,a_{i}})\min{(a_{i},a_{i+1},\cdots,a_{n}})\leq \sum_{i=1}^{t-1}\max({a_{1},a_{2},\cdots,a_{i}})\min{(a_{i},a_{i+1},\cdots,a_{t-1}})+ \sum_{j=t}^{n}\max({a_{t},a_{t+1},\cdots,a_{j}})\min{(a_{j},a_{j+1},\cdots,a_{n}})\leq (\cdots by-inductive-hypothesis \cdots)\leq \dfrac{t-1}{2\sqrt{t-2}}\sum_{i=1}^{t-1}a^2_{i}+\dfrac{n-t+1}{2\sqrt{n-t}}\sum_{i=t}^{n}a^2_{i}$$
$$\leq \dfrac{n}{2\sqrt{n-1}}\sum_{i=1}^{t-1}a^2_{i}+\dfrac{n}{2\sqrt{n-1}}\sum_{i=t}^{n}a^2_{i}$$
(If $t=2$, we should rewrite $ \dfrac{t-1}{2\sqrt{t-2}}\sum_{i=1}^{t-1}a^2_{i}$ as $a_1^2$ which is also less or equal to $ \dfrac{n}{2\sqrt{n-1}}\sum_{i=1}^{t-1}a^2_{i}$
If $t=n$, we should rewrite $\dfrac{n-t+1}{2\sqrt{n-t}}\sum_{i=t}^{n}a^2_{i}$ as $a_n^2$ which is also less or equal to $\dfrac{n}{2\sqrt{n-1}}\sum_{i=t}^{n}a^2_{i}$)
If $max(a_1,a_2,\cdots,a_n)=a_1$, then because
$\min{(a_{i},a_{i+1},\cdots,a_{n}})\leq a_i $ and also
$\min{(a_{1},a_{2},\cdots,a_{n}})\leq \dfrac {(a_2+a_3+\cdots+a_n)}{n-1}$
$$\sum_{i=1}^{n}\max({a_{1},a_{2},\cdots,a_{i}})\min{(a_{i},a_{i+1},\cdots,a_{n}})\leq a_1\dfrac {(a_2+a_3+\cdots+a_n)}{n-1}+\sum_{i=2}^{n} a_1a_i =\dfrac{n}{n-1}a_1(a_2+a_3+\cdots+a_n)=\dfrac{n}{2\sqrt{n-1}}\sum_{i=2}^{n}\dfrac {2}{\sqrt{n-1}}a_1a_i\leq \dfrac{n}{2\sqrt{n-1}}\sum_{i=2}^{n} (\dfrac{a_1^2}{n-1}+a_i^2)=\dfrac{n}{2\sqrt{n-1}}\sum_{i=1}^{n}a^2_{i} $$
So, this finishes the proof. The equality case is satisfied for $a_1=\sqrt{n-1}a_2$ and $a_2=a_3=\cdots=a_n$.