Prove the following summation inequality

$\sum_{i=1}^n(a_i)\sum_{i=1}^n(\frac{1}{a_i})\ge n^2$ is what I want to prove, where $a_i>0$ and I need to showwhen equality holds. I have tried using Cauchy-Schwarz, where inside the sums I multiply each value by 1 to do it but it doesn’t work out. I have also done

$\sum_{i=1}^n(a_i)\sum_{i=1}^n(\frac{1}{a_i})=\sum_{i=1}^n \sum_{i=1}^n(\frac{a_i}{a_i})=\sum_{i=1}^n\sum_{i=1}^n(1)=\sum_{i=1}^n(n)=n^2$, but this proves an equality.

Am I not allowed to do the first step I did in my work?

Solutions Collecting From Web of "Prove the following summation inequality"

By the Cauchy-Schwarz inequality,

$$\sum_{i = 1}^n a_i \sum_{i = 1}^n \frac{1}{a_i} \ge \left(\sum_{i = 1}^n \sqrt{a_i}\cdot \sqrt{\frac{1}{a_i}}\right)^2 =\left(\sum_{i = 1}^n 1\right)^2 = n^2.$$

Expanding GEdgar’s answer,

&=\sum_{i=1}^n \sum_{j=1}^n\frac{a_i}{a_j}\\
&=\sum_{i=1}^n \left(\sum_{j=1}^{i-1}\frac{a_i}{a_j}
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{a_i}{a_j}
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{a_i}{a_j}
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{a_i}{a_j}
\quad\text{ (swapping i and j in the last sum)}\\
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\left(\frac{a_i}{a_j}+\frac{a_j}{a_i}\right)
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\left(\frac{a_i^2+a_j^2}{a_i a_j}\right)
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\left(\frac{(a_i-a_j)^2+2a_i a_j}{a_i a_j}\right)
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\left(\frac{(a_i-a_j)^2}{a_i a_j}+2\right)
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{(a_i-a_j)^2}{a_i a_j}
+\sum_{i=1}^n \sum_{j=1}^{i-1}2
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{(a_i-a_j)^2}{a_i a_j}+\sum_{i=1}^n 2(i-1)+n\\
&=\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{(a_i-a_j)^2}{a_i a_j}+2\frac{n(n-1)}{2}+n\\
&=n^2+\sum_{i=1}^n \sum_{j=1}^{i-1}\frac{(a_i-a_j)^2}{a_i a_j}\\
&\ge n^2\\

with equality
if and only if
all the $a_i$ are equal.

For the first step
\sum_{i=1}^n(a_i)\sum_{i=1}^n(\frac{1}{a_i})=\sum_{i=1}^n \sum_{j=1}^n(\frac{a_i}{a_j})
The first factor has $n$ terms, the second factor has $n$ terms, and when you multiply them there are $n^2$ terms.

Can you see how to finish now?

(Late answer, but I just flagged a recent question as a duplicate of this one, and thought I’d leave yet another way to solve it here.)

The given inequality $\displaystyle\,\left(\sum_{i=1}^n a_i\right)\left(\sum_{i=1}^n\frac{1}{a_i}\right)\ge n^2\,$ is equivalent to $\;\displaystyle\,\frac{\displaystyle\;\sum_{i=1}^n a_i\;}{n} \ge \frac{n}{\displaystyle\;\sum_{i=1}^n \frac{1}{a_i}\;} \,$.

The latter is the $\text{AM} \ge \text{HM}$ inequality between the arithmetic and harmonic means of $\,n\,$ positive numbers, which holds true by the generalized mean inequality, with equality iff all $\,a_i\,$ are equal.