Could somebody explain how they derive the term in the red highlight.
What I get:
$$n\sum^n_{j=1}(x_j)^2-n^2\overline{x}^2=n\left(\sum x_j^2-n\overline{x}^2\right)$$ $$=n\left(\sum x^2_j-\frac{n}{n^2}\left(\sum x_j\right)^2\right)=n\left(\sum x_j^2-\frac{1}{n}\left(\sum x^2_j\right)\right)=n\left(\sum x^2_j-\overline{x}\sum x_j\right)$$
But this is nowhere near to what they get. How is this derived? If somebody could show me that would be great

We have $$ n\sum_{j=1}^n(x_j-\bar{x})^2=n\sum_{j=1}^n\left(x_j^2-2x_j\bar x+\bar{x}^2\right) $$ $$ =n\sum_{j=1}^n x_j^2-2n\bar{x}\sum_{j=1}^n x_j+n^2\bar{x}^2 $$ $$=n\sum_{j=1}^n x_j^2-2n\bar{x}n\bar{x}+n^2\bar{x}^2$$ $$=n\sum_{j=1}^n x_j^2-n^2\bar{x}^2.$$
The problem in your computation is that $\left(\sum_{j=1}^nx_j\right)^2\neq \sum_{j=1}^n x_j^2$.