How can I prove the following statement?
Given a function $U: A \subset \mathbb{R}^n \to \mathbb{R}$ with $A$ connected set, $$\nabla U=\bar{0} \,\,\,\,\,\,\, \forall \bar{x} \in A\implies U=\mathrm{constant} \,\,\,\,\,\,\, \forall \bar{x} \in A$$
In particular I do not understand how the condition of $A$ as a connected set is necessary to prove the statement.