3. If the inequality about $x$
$$
\frac{x^{2}+\left(2 a^{2}+2\right) x-a^{2}+4 a-7}{x^{2}+\left(a^{2}+4 a-5\right) x-a^{2}+4 a-7}<0
$$

has a solution set that is the union of some intervals, and the sum of the lengths of these intervals is less than 4, then the range of real number $a$ is $\qquad$
3. $a \in(-\infty, 1] \cup[3,+\infty)$.
$$
\text { Given } \begin{aligned}
\Delta_{1} & =\left(a^{2}+4 a-5\right)^{2}-4\left(-a^{2}+4 a-7\right) \\
& =\left(a^{2}+4 a-5\right)^{2}+4(a-2)^{2}+12
\end{aligned}
$$

we know that the equation
$$
x^{2}+\left(a^{2}+4 a-5\right) x-a^{2}+4 a-7=0
$$

has two distinct real roots $x_{1} 、 x_{2}\left(x_{1}<x_{2}\right)$.
Similarly, the equation $x^{2}+\left(2 a^{2}+2\right) x-a^{2}+4 a-7=0$ also has two distinct real roots $x_{3} 、 x_{4}\left(x_{3}<x_{4}\right)$.
$$
\begin{array}{l} 
\text { and }\left(a^{2}+4 a-5\right)-\left(2 a^{2}+2\right) \\
\quad=-a^{2}+4 a-7=-(a-2)^{2}-3<0,
\end{array}
$$

then $-\left(x_{1}+x_{2}\right)+\left(x_{3}+x_{4}\right)=x_{1} x_{2}=x_{3} x_{4}<0$.
Thus, $x_{3}+x_{4}<x_{1}+x_{2}$, and $x_{3}<x_{1}<0<x_{4}<x_{2}$.
Therefore, the solution set of the original inequality is $\left(x_{3}, x_{1}\right) \cup\left(x_{4}, x_{2}\right)$.
$$
\begin{array}{l}
\text { Also, }\left(x_{1}-x_{3}\right)+\left(x_{2}-x_{4}\right)=\left(x_{1}+x_{2}\right)-\left(x_{3}+x_{4}\right) \\
\quad=a^{2}-4 a+7 \leqslant 4,
\end{array}
$$

solving this gives $a \leqslant 1$ or $a \geqslant 3$.