Induction on $n\ge 2$. The base case $n=2$ is left to the readers.
By the induction hypothesis $\deg f\ge n-1$. If $\deg f\ge n$ then there is nothing to prove, so we may assume $\deg f=n-1$. Write $f(X)=b_{n-1}X^{n-1}+\cdots+b_1X+b_0$ with $b_{n-1}\ne0$. We have $f(a_i)=0$ for $1\le i\le n$, that is, $b_{n-1}a_i^{n-1}+\cdots+b_1a_i+b_0=0$ for $1\le i\le n$. Set $$A=\pmatrix{1&1&\dots&1\\a_1&a_2&\dots&a_n\\\cdots&\cdots&\cdots&\cdots\\a_1^{n-1}&a_2^{n-1}&\cdots&a_n^{n-1}}.$$ Then $(b_0\ b_1\ \dots\ b_{n-1})A=0$. But $\det A=\prod_{1\le i<j\le n}(a_j-a_i)\in R^*$, hence $A$ is invertible. Now we get $(b_0\ b_1\ \dots\ b_{n-1})=0$, a contradiction.