Unable to understand given Sample I/O

8
4 5 2 2 1 3 5 5
ans=4
I am unable to understand how 4 is the answer

4 5 2 2 1 3 5 5
Step 1 : 4 5 2 2 3 3 5 5
Step 2: 4 5 3 3 3 3 5 5
Step 3: 4 5 5 5 5 5 5 5
Step 4: 5 5 5 5 5 5 5 5

In 4 steps you can convert the given array into required form.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.