Q:

Twice the product of the terms gone from summand.

I'm having a hard time trying to understand why in the below expression the product of the terms is gone and only the squared terms is left inside the summation. 
The image is taken from a pdf file about Likelihood Ratio tests (here, page 4). The same approach is found on many other sources including my professor's, but I haven't found an exhaustive explanation.

A:

It is just some algebra with the mixed terms using that

$\sum_{i=1}^nX_i = n\bar X$

$$\sum_{i=1}^n(X_i - \bar X)(\bar X - \mu_0) = \sum_{i=1}^n(X_i\bar X - \mu_0X_i-\bar X^2 + \mu_0\bar X)$$
$$= n\bar X\bar X - \mu_0 n \bar X - n\bar X^2 + n\mu_0\bar X = 0$$
So, all mixed terms cancel each other.

