\[ \cos ^2(x) y''(x)-y(x) \left (a \cos ^2(x)+(n-1) n\right )=0 \] ✓ Mathematica : cpu = 0.449778 (sec), leaf count = 134
\[\left \{\left \{y(x)\to c_1 i^{1-n} \cos ^{1-n}(x) \, _2F_1\left (-\frac {n}{2}-\frac {i \sqrt {a}}{2}+\frac {1}{2},-\frac {n}{2}+\frac {i \sqrt {a}}{2}+\frac {1}{2};\frac {3}{2}-n;\cos ^2(x)\right )+c_2 i^n \cos ^n(x) \, _2F_1\left (\frac {n}{2}-\frac {i \sqrt {a}}{2},\frac {n}{2}+\frac {i \sqrt {a}}{2};n+\frac {1}{2};\cos ^2(x)\right )\right \}\right \}\] ✓ Maple : cpu = 0.382 (sec), leaf count = 123
\[ \left \{ y \left ( x \right ) ={\it \_C1}\,\sin \left ( 2\,x \right ) \left ( \cos \left ( x \right ) \right ) ^{-n}{\mbox {$_2$F$_1$}(1+{\frac {i}{2}}\sqrt {a}-{\frac {n}{2}},1-{\frac {i}{2}}\sqrt {a}-{\frac {n}{2}};\,{\frac {3}{2}}-n;\,{\frac {\cos \left ( 2\,x \right ) }{2}}+{\frac {1}{2}})}+{{\it \_C2}\, \left ( \cos \left ( x \right ) \right ) ^{n} \left ( -2\,\cos \left ( 2\,x \right ) +2 \right ) ^{{\frac {3}{4}}}{\mbox {$_2$F$_1$}({\frac {1}{2}}+{\frac {i}{2}}\sqrt {a}+{\frac {n}{2}},{\frac {1}{2}}-{\frac {i}{2}}\sqrt {a}+{\frac {n}{2}};\,n+{\frac {1}{2}};\,{\frac {\cos \left ( 2\,x \right ) }{2}}+{\frac {1}{2}})}\sqrt [4]{2\,\cos \left ( 2\,x \right ) +2}{\frac {1}{\sqrt {\sin \left ( 2\,x \right ) }}}} \right \} \]