From Inequalities A Mathematical Olympiad Approach, page 122
Observe that, $$\sum_{i = 1}^n \sqrt{a_i}-(n-1)\sum_{i = 1}^n \dfrac{1}{\sqrt{a_i}} = \sum_{i = 1}^n \dfrac{1}{1+a_i}\sum \sqrt{a_i} - \sum_{i = 1}^n \dfrac{a_i}{1+a_i} \sum_{i = 1}^n \dfrac{1}{\sqrt{a_i}}\\ = \sum_{i,j} \dfrac{a_i-a_j}{(1+a_j)\sqrt{a_i}} = \sum_{i>j} \dfrac{(\sqrt{a_i}\sqrt{a_j}-1)(\sqrt{a_i}-\sqrt{a_j})^2(\sqrt{a_i}+\sqrt{a_j})}{(1+a_i)(1+a_j)\sqrt{a_i}\sqrt{a_j}}$$
I get that one $1+a_j$ factor in the denominator is from the given summation condition and the we applied $a^2-b^2$ for square root in the numerator to get two factors. But where do other factors come from? Also in the summation in the last step, how did we say $i>j$?