Simplifying $\sum(Y_i-\bar{Y})^2$ My textbook tells me that for a random sample $Y_1, Y_2, \dots, Y_n$ where $E(Y_i)=\mu, V(Y_i)=\sigma^2$:
$\displaystyle\sum_{i=1}^n (Y_i-\bar{Y})^2 = \sum_{i=1}^nY_i^2-\frac{1}{n}(\sum_{i=1}^n Y_i)^2 = \sum_{i=1}^n Y_i^2-n\bar{Y}^2$
I'm sorry if this is a horrifically dumb question, but I don't understand how these are equivalent. When I do the math on the first summation on the lefthand side (aka foil it out), I have a $-2Y_i\bar{Y}$ term that isn't represented in the middle equation.
Again, my apologies if this is not the correct place for a silly algebra question such as this. I will delete if necessary.

The book made two steps at once. When you expand $(Y_i - \overline{Y})^2$, you get the $-2Y_i\overline{Y}$ term you noted, but you also get a $+\overline{Y}^2$ term. When you sum, things cancel:
\begin{align}
\sum_{i=1}^n (Y_i - \overline{Y})^2 &= \sum_{i=1}^n (Y_i^2 - 2 Y_i\overline{Y} + \overline{Y}^2)\\
&= \sum_{i=1}^n Y_i^2 - 2\overline{Y}\underbrace{\sum_{i=1}^n Y_i}_{n\cdot \overline{Y}} + n\cdot \overline{Y}^2\\
&= \sum_{i=1}^n Y_i^2 - 2n\overline{Y}^2 + n\overline{Y}^2\\
&= \sum_{i=1}^n Y_i^2 - n\overline{Y}^2.
\end{align}
