Question: Suppose that $f:[a,b]\to\mathbb{R}$ is continuous. Let $x_1,x_2,\cdots, x_n$ be any $n$ points in $(a,b).$ Show that there exists $x_0\in(a,b)$ such that $$f(x_0)=\frac{1}{n}(f(x_1)+f(x_2)+\cdots+f(x_n)).$$
Solution: Let $g:[a,b]\to\mathbb{R}$ be such that $$g(x)=nf(x)-\sum_{k=1}^nf(x_k), \forall x\in[a,b].$$ Observe that to prove the statement of the problem it is enough to show that $g(x_0)=0$ for some $x_0\in(a,b)$.
Now note that by the 3rd form of the Pigeon Hole principle we can conclude that there exists $1\le i,j\le n$ such that $$f(x_i)\le \frac{1}{n}\sum_{k=1}^nf(x_k)\le f(x_j)\\\implies nf(x_i)\le \sum_{k=1}^nf(x_k)\le nf(x_j).$$ Thus, $g(x_i)=nf(x_i)-\sum_{k=1}^nf(x_k)\le 0$ and $g(x_j)=nf(x_j)-\sum_{k=1}^nf(x_k)\ge 0.$ Now if $g(x_i)=0$ or $g(x_j)=0$, then we are done. Thus, let us assume that $g(x_i)<0$ and $g(x_j)>0$. Now since $f$ is continuous on $[a,b]$, implies that $g$ is continuous on $[a,b]$. Therefore, by IVT we can conclude that there exists $x_0\in(x_i,x_j)$ or $x_0\in(x_j,x_i)$ such that $g(x_0)=0$. This completes the proof.
Is this solution correct and rigorous enough and is there any other way to solve the problem?