I was trying to follow the proof that shows that $a = \overline{y}$ in the least squares regression line $$\hat{y_i}=a + b(x_i - \overline{x})$$
but I don't understand why $\sum_{i=1}^{n} (x_i - \overline{x}) = 0$. The following is the proof:
In order to derive the formulas for the intercept a and slope b, we need to minimize: $$Q = \sum_{i=1}^{n}(y_i - (a + b(x_i - \overline{x})))^2$$ Starting with the derivative of $Q$ with respect to $a$, we get: $$\frac{\partial Q}{\partial a} = 2 \sum_{i=1}^{n} (y_i - (a + b(x_i - \overline{x}))) (-1) \stackrel{SET}{=} 0 $$
Now, we solve for $a$: \begin{align*} -\sum_{i=1}^{n} (y_i - (a + b(x_i - \overline{x}))) &= 0\\ -\sum_{i=1}^{n} y_i + \sum_{i=1}^{n} a + b \sum_{i=1}^{n} (x_i - \overline{x}) &=\\ -\sum_{i=1}^{n} y_i + n a + 0 &= \\ a &= \frac{\sum_{i=1}^{n} y_i}{n} = \overline{y} \end{align*}
$$\sum_{i=1}^{n} (x_i - \overline{x})=\sum_{i=1}^{n} x_i - \sum_{i=1}^{n}\overline{x}$$
$$=\sum_{i=1}^{n} x_i-n\overline{x}$$
$$=\sum_{i=1}^{n} x_i-n\frac{\sum_{i=1}^{n} x_i}{n}=0$$