How is the second equeation in red cricle is derived from the first equation? I am wondering how the equation in red circle derived from the first equation. I am sorry if I have place tags in the wrong place.


Since
$$\overline{x}=\frac{1}{n}\sum_{i=1}^nx_i,\quad \overline{y}=\frac{1}{n}\sum_{i=1}^ny_i,\quad n=\sum_{i=1}^n1,$$
we have
$$\begin{align}
-n\overline{x}\;\overline{y}-n\overline{x}\;\overline{y}+n\overline{x}\;\overline{y}&=-n\left(\frac{1}{n}\sum_{i=1}^nx_i\right)\;\overline{y}-n\overline{x}\;\left(\frac{1}{n}\sum_{i=1}^ny_i\right)+\left(\sum_{i=1}^n1\right)\overline{x}\;\overline{y}\\
&=-\overline{y}\sum_{i=1}^nx_i-\overline{x}\;\sum_{i=1}^ny_i+\sum_{i=1}^n\overline{x}\;\overline{y}\end{align}$$
