Can a bounded function always attain its least upper bound on a bounded rectangle in $R^n$? Suppose we have a rectangle $Q$, and $Q\subset R^n$. Then $Q$ is bounded by the definition of higher dimensional rectangles. Suppose $f$ is a bounded function defined on $Q$. Since $f$ is bounded, we can produce its infimum $\inf_Q f$ and supremum $\sup_Q f$. My question is that is it always true that $\exists x_1,x_2\in Q$ with the property that $f(x_1)=\inf_Q f$ and $f(x_2)=\sup_Q f$?
If this does not always hold, please provide an example.

Consider the rectangle $Q$ given by $(0,1)^n\subset \mathbb R^n$ with coordinates $x_1\cdots x_n$. Then the function $f(x_1\cdots x_n)=x_1$ is bounded on $Q$ but attains neither its supremum on $Q$ (which is $1$) nor its infimum on $Q$ (which is $0$).
