From Lagrange theorem it follows that there exist such that
so we can assume or for all
(otherwise the proof it trivial). Suppose we have and for some .
If then we're done.
If then and thus the existence of such
that is guaranteed by the intermediate value theorem for derivatives and we're done.
Otherwise and so either or . Either
way, using the intermediate value theorem for derivatives we're done again.
Now suppose the previous case is not true. That is, for all or for all
Therefore the function is either monotone increasing or monotone decreasing (by looking at the derivative).
Either way, it means that . But from the conditions on it follows that , a contradiction.