Deriving Vieta's formulas: where is my mistake? I am having trouble deriving Vieta's formulas. Concretely, If $p(x) = a_0 + a_1 x + \dots + a_n x^n = (x-x_1)\dots(x-x_n)$ where $a_i$ are complex coefficients and $x_i$ are complex roots then according to Wikipedia:
$$ \sum x_i = -{a_{n-1}\over a_n}$$
and
$$ x_1x_2\dots x_n = (-1)^n {a_0\over a_n}$$
I can derive the latter by comparing $a_0 + a_1 x + \dots + a_n x^n $ with $ (x-x_1)\dots(x-x_n)$: the only term that does not contain $x$ in the product  $ (x-x_1)\dots(x-x_n)$ is $(-x_1)(-x_2)\dots (-x_n)=(-1)^n x_1\dots x_n$ and since the product is monic we must have
$$ (-1)^n x_1\dots x_n = {a_0\over a_n}$$
I tried to use the same reasoning for the other equality but ran into trouble. Concretely, the only terms of order $1$ in the product are $-x_i x$. Therefore, we'd have to have $\sum -x_i = {a_1\over a_n}$.

Please could someone point out the mistake in my reasoning?

 A: Note that
\begin{align*}
p(x)=a_0+a_1x+\cdots+a_nx^n=\color{blue}{a_n}(x-x_1)\cdots(x-x_n)
\end{align*}

It is convenient to use the coefficient of operator $[x^k]$ to denote the coefficient of $x^k$ in a polynomial.
Since
  \begin{align*}
a_0&=[x^0]p(x)\\
&=[x^0]a_n(x-x_1)(x-x_2)\cdots(x-x_n)\tag{1}\\
&=a_n(-x_1)(-x_2)\cdots (-x_n)\\
&=a_n(-1)^nx_1x_2\cdots x_n\\
\end{align*}
  we get
  \begin{align*}
(-1)^n\frac{a_0}{a_n}&=x_1x_2\cdots x_n
\end{align*}

In (1) we see that only the constant term in a factor $(x-x_j), 1\leq j\leq n$ contributes to $a_0$.

Since
  \begin{align*}
a_{n-1}&=[x^{n-1}]p(x)\\
&=[x^{n-1}]a_n(x-x_1)\cdots(x-x_n)\tag{2}\\
&=[x^{n-1}]\left(-a_nx_1x^{n-1}-a_nx_2x^{n-1}-\cdots-a_nx_nx^{n-1}\right)\tag{3}\\
&=a_n\left(-x_1-x_2-\cdots-x_n\right)\\
\end{align*}
  we get
  \begin{align*}
-\frac{a_{n-1}}{a_n}=x_1+x_2+\cdots+x_n
\end{align*}

In (2) we see that $n-1$ factors of $(x-x_j), 1\leq j\leq n$ have to contribute $x$ in order to get $x^{n-1}$ while one factor has to contribute the constant term. In (3) we select the coefficient of $x^{n-1}$.
A: Every term is a product of $n$ factors. The terms of order $1$ are therefore the product of $n-1$ constants $-x_{k_1},-x_{k_2},\ldots,-x_{k_{n-1}}$ and a single $x$.
