Consider the sum of squared residuals of a linear regression given by
$$ S_i(a,b) = \sum_{i=1}^n (y_i-a-bx_i)^2$$
I have to show that the optimal values of $a$ and $b$ found using the first-order conditions do indeed minimize $S_i(a,b)$. After some calculations, we find that the Hessian matrix is
$$ H = \begin{bmatrix} 2n & 2\sum_{i=1}^n x_i \\ 2\sum_{i=1}^n x_i & 2\sum_{i=1}^nx_i^2 \end{bmatrix}$$
Now, $2n > 0$. So it remains to show
$$ 4 \cdot \left(n\sum_{i=1}^n x_i^2 - (\sum_{i=1}^n x_i)^2\right) > 0 $$
Looking online I found that
$$ \left(n\sum_{i=1}^n x_i^2 - (\sum_{i=1}^n x_i)^2\right) = n \cdot \sum_{i=1}^n (x_i-\bar{x})^2 > 0$$
where $\bar{x}$ is the mean. I can't see how to go from the expression on the left to the one on the right.
I'd appreciate it if someone could explain it to me.