Four. (30 points) Let the function
$$
f(x)=\ln x+a\left(\frac{1}{x}-1\right)(a \in \mathbf{R}),
$$

and the minimum value of $f(x)$ is 0.
(1) Find the value of $a$;
(2) If the sequence $\left\{a_{n}\right\}$ satisfies
$$
a_{1}=1, a_{n+1}=f\left(a_{n}\right)+2\left(n \in \mathbf{Z}_{+}\right),
$$

let $S_{n}=\left[a_{1}\right]+\left[a_{2}\right]+\cdots+\left[a_{n}\right],[m]$ denote the greatest integer not exceeding the real number $m$, find $S_{n}$.
(1) $f^{\prime}(x)=\frac{1}{x}-\frac{a}{x^{2}}=\frac{x-a}{x^{2}}(x>0)$.
When $a \leqslant 0$, $f^{\prime}(x)>0$, then $f(x)$ is monotonically increasing in the interval $(0,+\infty)$, with no minimum value, which does not meet the requirement.
When $a>0$,
if $0<a$, then $f^{\prime}(x)>0$.
Therefore, the function $f(x)$ is monotonically decreasing in the interval $(0, a)$ and monotonically increasing in the interval $(a,+\infty)$.
Hence $f(x)_{\min }=f(a)=\ln a-a+1$.
Let $g(a)=\ln a-a+1(a>0)$. Then
$g^{\prime}(a)=\frac{1}{a}-1=\frac{1-a}{a}$.
If $0<a<1$, then $g^{\prime}(a)>0$;
If $a>1$, then $g^{\prime}(a)<0$.
Therefore, $g(a)$ is monotonically increasing in the interval $(0,1)$ and monotonically decreasing in the interval $(1,+\infty)$.
Thus, $g(a)_{\max }=g(1)=0$.
Since $g(a)$ is continuous and $g(2)=\ln 2-1<0$, there exists a unique $a_0 \in (1,2)$ such that $g(a_0)=0$.
Therefore, when $0<a<a_0$, $g(a)<0$; when $a>a_0$, $g(a)<0$.
Since $g(2)=\ln 2-1<0$, $g(3)=\ln 3-2<0$, we have $a_0 \in (2,3)$.
Let $a_k \in (2,3)$, then
$h(a_k)=\ln a_k-a_k+1<0$,
$\Rightarrow 2<h(a_k)<3$
$\Rightarrow 2<a_{k+1}<3$,

That is, when $n=k+1$, the conclusion also holds.
By induction, we know that for all integers $n \geqslant 3$,
$2<a_{n}<3$.
Thus, $\left[a_{1}\right]=1,\left[a_{n}\right]=2(n \geqslant 2)$.
Hence $S_{n}=\left[a_{1}\right]+\left[a_{2}\right]+\cdots+\left[a_{n}\right]$
$=1+2(n-1)=2 n-1$.