4. Let $a>0, a \neq 1$,
$$
f(x)=\log _{a}\left(x+\sqrt{x^{2}-1}\right)(x \geqslant 1) \text {. }
$$

If $f^{-1}(n)<\frac{3^{n}+3^{-n}}{2}$, where $n$ is a positive integer, then the range of $a$ is ( ).
(A) $\left(0, \frac{1}{3}\right)$
(B) $\left(\frac{1}{3}, 1\right) \cup(1,3)$
(C) $(1,3)$
(D) $(1,+\infty)$
4.C.

It is easy to get $f^{-1}(x)=\frac{1}{2}\left(a^{x}+a^{-x}\right)$.
When $0<1$, we get $f(x) \geqslant 0$.
In $f^{-1}(n)$, $n>0$, so $a>1$.
$$
\begin{array}{l}
\text { By } \frac{a^{n}+a^{-n}}{2}<\frac{3^{n}+3^{-n}}{2} \\
\Rightarrow\left(3^{n}-a^{n}\right)\left(1-3^{n} a^{n}\right)<0 \\
\Rightarrow\left(\frac{1}{3}\right)^{n}<a^{n}<3^{n} \Rightarrow \frac{1}{3}<a<3 \\
\Rightarrow 1<a<3 .
\end{array}
$$