5. Find all integer values of $a$ such that the equation $(a+1) x^{2}-\left(a^{2}+1\right) x+2 a^{3}-6$ $=0$ has integer roots.
(1996, Huanggang Region, Hubei Province Junior High School Mathematics Competition)
(Tip: Discuss separately for $a=-1, a \neq-1$, $a=-1,0,1$)