Let $a_1,\ldots,a_n$ real numbers and $x_1,\ldots,x_n$ be distinct real numbers. Show that there is a polynomial of degree at most $n-1$ for which $f(x_i) = a_i$ for all $i$.
My idea was to prove the statement for $a_1 = 1$ and $a_2 = \cdots = a_n = 0$. We then have $f(x_1) = 1$ and $f(x_m) = 0$ for $1 < n \leq m$. Then I have to construct such a function and see how to construct a function for any sequence of $a_i's$ and $x_i's$.