Test case 1 and 3 are not working , please check

Consider this case
5
5 4 3 2 1
5
9 8 7 6 5

your code output is
1, 5, 2, 10, 8, 6, END
but correct one is
1, 5, 3, 0, 8, 6, END

i hope you understand your mistake
see the Modified Code
Modified code

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask