Getting WA but can't figure out why

I used kind of a greedy approach but why it is wrong , i can’t figure that out ??

@aryan_007 try this simple input test case
5
1 2 3 40 70
answer should be 113, but your output is 74.

1 Like

Okayyyyyy sir , got it , Thanks :slightly_smiling_face: :slightly_smiling_face: