Computing an almost Vandermonde matrix
Hint:
Consider $$D = \begin{vmatrix} 1&x&x^2&\cdots&x^{n-2} & x^{n-1}&x^n\\ 1&a_1&a_1^2&\cdots&a_1^{n-2} & a_1^{n-1}&a_1^n\\ 1&a_2&a_2^2&\cdots&a_2^{n-2} & a_2^{n-1}&a_2^n\\ \vdots\\ 1&a_n&a_n^2&\cdots&a_n^{n-2} & a_n^{n-1}&a_n^n\\ \end{vmatrix}$$
This is a Vandermonde determinant, so you already know how to calculate it. Look for the coefficient of $x^{n-1}$. On the other hand develop the determinant using the first row.
In a similar way, you can see the following generalization: $$\begin{vmatrix} 1&a_1&\cdots&a_1^{k-1}&a_1^{k+1}\cdots &a_1^n\\ 1&a_2&\cdots&a_2^{k-1}&a_2^{k+1}\cdots &a_2^n\\ \vdots\\ 1&a_n&\cdots&a_n^{k-1}&a_n^{k+1}\cdots &a_n^n\\ \end{vmatrix} = \sigma_{n-k}(a_1,a_2\cdots,a_n)\prod_{i<j}(a_j-a_i)$$
(Here $\sigma_k$ denotes the $k$-th elementary symmetric polynomial)