Note $\, a_i\ne a_j\, \Rightarrow\, x\!-\!a_i\ $ are nonassociate primes in $R[x]$ since $ R[x]/(x\!-\!a_i) \cong R\:$ is a domain.
Hence $\ x\!-\!a_1\ |\ f(x),\, \ldots,\, x\!-\!a_n\ |\ f(x)\, \Rightarrow\ \ (x\!-\!a_1)\cdots (x\!-\!a_n)\ |\ f(x) $
since LCM = product for nonassociate primes. But this is contra degree if $\ n > \deg f$.
Remark $\, D\,$ is a domain $\!\iff\!$ every polynomial $\,f(x)\neq 0\in D[x]\, $ has at most $\, \deg f $ roots in $\,D.\,$ For the simple proof see my here, where I illustrate it constructively in $\,\Bbb Z/m\, $ by showing that given any $\,f(x)\,$ with more roots than its degree,$\:$ we can quickly compute a nontrivial factor of $\,m\,$ via a simple gcd computation. The quadratic case of this result is at the heart of many integer factorization algorithms, which try to factor $\:m\:$ by searching for a square root of $1$ that's $\not\equiv \pm1\,$ in $\: \mathbb Z/m$.