[Math] How to reduce this double summation in to a single summation

summation

So I was participating in this contest and now that it's over I was checking the editorial for the author solution. Basically the solution was deriving a single summation from a double summation in order to have a more efficient solution ..

But I couldn't understand one step in the derivation bellow .. I've highlighted the unclear step bellow .. I've tried to derive it but I could not .. Any hints about this are appreciated ..

$\sum_{i=1}^{k-1} \sum_{j=1}^{k-1} (b_i – b_j)^2$

$\implies \sum_{i=1}^{k-1} \sum_{j=1}^{k-1} (b_i^2 + b_j^2 – 2 . b_i . b_j)$

$\implies 2.k .\sum_{i=1}^{k-1} (b_i^2) – 2 . \sum_{i=1}^{k-1} \sum_{j=1}^{k-1} b_i . b_j$

$ \implies 2.k .\sum_{i=1}^{k-1} (b_i)^2 – 2 . (\sum_{i=1}^{k-1} b_i)^2 $

                        ^ this step 

Best Answer

$$\sum_i (\sum_j b_i \cdot b_j) = \sum_i (b_i \cdot \sum_j b_j) = (\sum_j b_j) \cdot (\sum_i b_i)$$