# Unclear step in derivation of optimality equation for state-value function

By substituting the optimal value function into the Bellman equation, we get the Bellman equation for $$v_{\star}$$

$$v_{\star}(s) = \sum\limits_a \pi_{\star}(a|s) \sum\limits_{s'} \sum_r p(s', r | s, a)[r + \gamma v_{\star}(s')]$$

From the above equation, how can we obtain the this one?:

$$v_{\star}(s) = \max\limits_a \sum\limits_{s'} \sum\limits_r p(s', r|s,a) [r + \gamma v_{\star}(s')])$$

$$$$\pi_{\star}(a | s) = \begin{cases} 1 & \text{if a = }\text{a}_{\star},\\ 0 & \text{otherwise}\\ \end{cases}$$$$ Where $$a_{\star}$$ is the best action that can be taken in $$s$$, hence $$a_{\star} = \text{argmax}_a q(s,a)$$.
Then $$$$v_{\star}(s) = \sum_{a} \pi_{\star}(a | s) \sum_{s',r}p(s', r|s,a)[r + \gamma v_{\star}(s')] = \sum_{a} \pi_{\star}(a | s)q_{\star}(s, a) = q_{\star}(s, a_{\star}) = \max\limits_a q_{\star}(s, a) = \max\limits_a \sum_{s',r}p(s', r|s,a_{\star})[r + \gamma v_{\ast}(s')]$$$$
I used the equality $$\sum_{s',r}p(s', r|s,a)[r + \gamma v_{\star}(s')] = q_{\star}(s, a)$$ which is given by Sutton's "Reinforcement Learning: An Introduction" (second edition) at equation (3.20) combined with (3.19) in straight-forward fashion.