4. Given a positive integer $n \geq 3$, if a positive real number $k>1$ satisfies: if positive real numbers $x_{1}, x_{2}, \cdots x_{n}$ satisfy $\sum_{i=1}^{n} x_{i}=k \sum_{i=1}^{n} \frac{1}{x_{i}}$, then it must be true that $\sum_{i=1}^{n} \frac{x_{i}^{2}}{x_{i}^{2}+1} \leq k \sum_{i=1}^{n} \frac{1}{x_{i}^{2}+1}$, then it is called a "good number". Try to find the smallest good number $k$.
【Answer】The smallest good number is $n-1$. (3 points)
【Explanation】The inequality to be proved is equivalent to $\sum_{i=1}^{n} \frac{x_{i}^{2}}{x_{i}^{2}+1} \leq n-1$. If there exist $x_{i}, x_{j}(i \neq j)$ such that $\frac{x_{i}^{2}}{x_{i}^{2}+1}+\frac{x_{j}^{2}}{x_{j}^{2}+1} \leq 1$, then the original inequality holds directly. (6 points)

Assume that for any $x_{i}, x_{j}(i \neq j)$, we have $\frac{x_{i}^{2}}{x_{i}^{2}+1}+\frac{x_{j}^{2}}{x_{j}^{2}+1}>1$,
which means $x_{i}^{2}\left(x_{j}^{2}+1\right)+x_{j}^{2}\left(x_{i}^{2}+1\right)>\left(x_{i}^{2}+1\right)\left(x_{j}^{2}+1\right) \Leftrightarrow x_{i}^{2} x_{j}^{2}>1 \Leftrightarrow x_{i} x_{j}>1$, (9 points)

【Proof 1】Transform the inequality to be proved into $\sum_{i=1}^{n} \frac{1}{x_{i}} \sum_{i=1}^{n} \frac{x_{i}^{2}}{x_{i}^{2}+1} \leq \sum_{i=1}^{n} x_{i} \sum_{i=1}^{n} \frac{1}{x_{i}^{2}+1}$. We prove that when $x_{i} x_{j}>1$,
$\frac{1}{x_{j}} \frac{x_{i}^{2}}{x_{i}^{2}+1}+\frac{1}{x_{i}} \frac{x_{j}^{2}}{x_{j}^{2}+1} \leq x_{j} \frac{1}{x_{i}^{2}+1}+x_{i} \frac{1}{x_{j}^{2}+1}$, thus the original inequality holds. (12 points)
Simplifying the above expression, it is equivalent to $x_{i}^{2} x_{j}\left(x_{i}^{2}+1\right)+x_{j}^{2} x_{i}\left(x_{j}^{2}+1\right) \geq x_{j}^{3}\left(x_{i}^{2}+1\right)+x_{i}^{3}\left(x_{j}^{2}+1\right)$, which is $\left(x_{i} x_{j}-1\right)\left(x_{i}-x_{j}\right)^{2}\left(x_{i}+x_{j}\right) \geq 0$, which holds. (15 points)

【Proof 2】Notice that the condition is equivalent to $\sum_{i=1}^{n} \frac{x_{i}^{2}-(n-1)}{x_{i}}=0$, and the inequality to be proved is equivalent to $\sum_{i=1}^{n} \frac{x_{i}^{2}-(n-1)}{x_{i}^{2}+1} \leq 0$, which is $\sum_{i=1}^{n} \frac{x_{i}^{2}-(n-1)}{x_{i}^{2}+1} \leq 0 \Leftrightarrow \sum_{i=1}^{n} \frac{x_{i}^{2}-(n-1)}{x_{i}} \cdot \frac{x_{i}}{x_{i}^{2}+1} \leq 0$. (12 points)

Notice that $\left(\frac{x_{i}}{x_{i}^{2}+1}-\frac{x_{j}}{x_{j}^{2}+1}\right)\left(x_{i}-x_{j}\right) \leq 0$, which is equivalent to $\left(1-x_{i} x_{j}\right)\left(x_{i}-x_{j}\right)^{2} \leq 0$, which holds.
Thus, by Chebyshev's inequality, the original inequality holds. (15 points)
We now show that if $1k \sum_{i=1}^{n} \frac{1}{x_{i}^{2}+1}$. Let $x_{1}=a, x_{i}=b(2 \leq i \leq n)$, and $\frac{a^{2}-k}{a}+(n-1) \frac{b^{2}-k}{b}=0$, we only need to find $a, b$ such that: $\frac{a^{2}-k}{a^{2}+1}+(n-1) \frac{b^{2}-k}{b^{2}+1}>0$. (18 points) Let $\frac{a^{2}-k}{a}=-(n-1) t, \frac{b^{2}-k}{b}=t$, where we let $t>\max \left(\sqrt{\frac{(n-1)^{2}-k^{2}}{4 k^{3}}}, \sqrt{\frac{4 k}{2 n-1}}\right)$,

Thus $a=\frac{-(n-1) t+\sqrt{(n-1)^{2} t^{2}+4 k}}{2}, b=\frac{t+\sqrt{t^{2}+4 k}}{2}$ are both positive.
And $\frac{a^{2}-k}{a^{2}+1}+(n-1) \frac{b^{2}-k}{b^{2}+1}=\frac{-(n-1) t a}{a^{2}+1}+(n-1) \frac{t b}{b^{2}+1}=\frac{(n-1) t}{\left(a^{2}+1\right)\left(b^{2}+1\right)}(b-a)(1-a b)$,
In fact, $b-a>0 \Leftarrow n t>\sqrt{(n-1)^{2} t^{2}+4 k} \Leftrightarrow(2 n-1) t^{2}>4 k$, which holds.
$$
\begin{array}{l}
1-a b>0 \Leftrightarrow 1>\frac{-(n-1) t+\sqrt{(n-1)^{2} t^{2}+4 k}}{2} \cdot \frac{t+\sqrt{t^{2}+4 k}}{2} \Leftrightarrow(n-1) t+\sqrt{(n-1)^{2} t^{2}+4 k}>k\left(t+\sqrt{t^{2}+4 k}\right) \\
\Leftarrow(n-1)^{2} t^{2}+4 k>k^{2}\left(t^{2}+4 k\right) \Leftarrow\left((n-1)^{2}-k^{2}\right) t^{2}>4 k^{3} \text {, which holds. (21 points) } \\
\end{array}
$$