I would like to ask for help with the next problem:
Let $a,b \in \mathbb{R}$ such that $a<b$. We define \begin{equation} B = \{x=(x_{1},\cdots,x_{n}) \in \mathbb{R}^{n} | (\forall i \in \{1,\cdots,n\}) \hspace{1cm} a \leq x_{i} \leq b\}, \end{equation} and \begin{equation} D = \{x=(x_{1},\cdots,x_{n}) \in \mathbb{R}^{n} | (\forall i,j \in \{1,\cdots,n\}) \hspace{1cm} x_{i}=x_{j}\}. \end{equation} Show that $\forall x \in \mathbb{R}^{n}, x$ has an unique projection on $B \cap D$ and is given by \begin{equation} (\forall i \in \{1,\cdots,n\}) \hspace{1cm} (P_{B \cap D} x)_{i} = \min\{b,\max\{a,\bar{x}\}\}, \end{equation} where $\bar{x} = \dfrac{\left(\sum_{i=1}^{n} x_{i}\right)}{n}$.
Any help will be appreciated.