Based on the tags, I'm assuming that the $x_i$ and $a_i$ are supposed to be integers. The procedure below generalizes to the case where you want simultaneous solutions to multiple equations. (It also works the same way if we use any principal ideal domain in place of integers.)
Write the inputs as a $1 \times n$ matrix $X = \begin{pmatrix}x_1 & \dotsb & x_n\end{pmatrix}$; assume $X \ne 0$ or else the problem is trivial. The problem is to find the vectors $A = \begin{pmatrix}a_1 & \dotsb & a_n\end{pmatrix}^T$ such that $XA = 0$. Smith normal form says that we can find an invertible $n \times n$ matrix $T$ such that $XT = \begin{pmatrix}d & 0 & \dotsb & 0\end{pmatrix}$, where $d = \gcd(x_1, \dotsc, x_n)$. (There would also be a $1 \times 1$ matrix $S$ that goes on the left, but we can just take it to be $1$.) (from Procedures to find solution to $a_1x_1+\cdots+a_nx_n = 0$)
So, what happens if $X$ contains zero entry - but is not zero vector?