Painter's Problem

Test case 0,1,2,3 not getting passed please verify the logic and provide me the test case.

Painter’s Problem

Consider a case:
5
2
5
1 10 40 40 50

Expected Output:
450

Your O/p:
500

Dry run your code with this case to verify.
I would recommend you to go through the online video lecture on the problem to understand it better,

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.