Suppose that the function $f:[0,1] \to \mathbb{R}$ is continuous on $[0,1]$ and $f(0)=f(1)$. Prove that for each natural number $n$, there exists $x_n \in \mathbb{R}$ such that $0 \leq x_n \leq 1-\frac{1}{n}$ and $f(x_n)=f(x_n+\frac{1}{n})$.
Though I don't know how the proof would look like, I have a strong feeling that it has something to do with the Intermediate Value Theorem, judging by the continuity of $f$ and the existence of such a $x_n$. So I guess I'm supposed to define a function $g(x)=f(x)-f(x+\frac{1}{n})$ on $[0,\frac{1}{n}]$ and try to claim that $g(x_n)=0$ for some $x_n \in [0,\frac{1}{n}]$. Unfortunately I don't know how to proceed further from here, maybe because I haven't made use of the fact that $f(0)=f(1)$.
Any hint and suggestion is much appreciated. Thank you!