We want to define a polynomial $p$ of degree (at most) $n$ which passes through $\left(a_1, b_1\right), \ldots,\left(a_{n+1}, b_{n+1}\right)$ where we assume all the $a_i$ 's are distinct. Suppose we could define polynomials $q_i$ having degree at most $n$ so that $q_i\left(a_i\right)=1$ and $q_i\left(a_j\right)=0$ for $i=1, \ldots, n+1$ and $j \neq i$. Show that we may take $p=b_1 q_1+\cdots+b_{n+1} q_{n+1}$. To construct the $q_i$, let's provide some guidance. You may or may not recall that if a polynomial $q(x)$ with real coefficients has a root $a$, then $(x-a)$ is a factor, that is $q(x)=(x-a) q_0(x)$. Even if you don't recall that fact, it should be clear that the polynomial $q(x)=\left(x-a_2\right)\left(x-a_3\right) \cdots\left(x-a_{n+1}\right)$ has the property that $q\left(a_i\right)=0$ for $i=2, \ldots, n+1$, and that $q\left(a_1\right)=\left(a_1-a_2\right)\left(a_1-a_3\right) \cdots\left(a_1-\right.$ $\left.a_{n+1}\right) \neq 0$ precisely because the $a_i$ 's are all distinct. So we may take $q_1(x)=q(x) / q\left(a_1\right)$ as the first element of our set. The others are similarly constructed.