6.5. (SFRY, 72). For each value of $a \in \mathbb{R}$, solve the equation

$$
(a-1)\left(\frac{1}{\sin x}+\frac{1}{\cos x}+\frac{1}{\sin x \cos x}\right)=2
$$
6.5. Transforming the left side of the equation, we get

$$
\begin{aligned}
& (a-1)\left(\frac{1}{\sin x}+\frac{1}{\cos x}+\frac{1}{\sin x \cos x}\right)=(a-1)\left(\frac{\cos x+\sin x+1}{\sin x \cos x}\right)= \\
& =(a-1)\left(\frac{\sqrt{2} \sin (x+\pi / 4)+1}{\sin ^{2}(x+\pi / 4)-\frac{1}{2}}\right), \text { i.e., } \sin ^{2}(x+\pi / 4) \neq 1 / 2
\end{aligned}
$$

Therefore,

$$
\frac{2(a-1)}{\sqrt{2} \sin (x+\pi / 4)-1}=2, \text { or } \sin (x+\pi / 4)=a / \sqrt{2} \neq \pm 1 / \sqrt{2}
$$

The last relation has no solutions when $|a|>\sqrt{2}$ or when $|a|=1$, and has solutions for other values of $a$. Thus, in the case $|a| \in\{1\} \cup(\sqrt{2} ;+\infty)$, the original equation has no solutions. If $|a| \in[0 ; 1) \cup(1 ; \sqrt{2}]$, then the original equation has solutions

$$
x=(-1)^{n} \arcsin (a \sqrt{2} / 2)-\pi / 4+\pi n
$$

where $n \in \mathbf{Z}$ for $|a| \in[0 ; 1) \cup(1 ; \sqrt{2}[$ and $n / 2 \in \mathbf{Z}$ for $|a|=\sqrt{2}$.