Solution in not correct for all the cases


#1

For input [1 5 2] it gives 4 and for [1 2 5] it gives 6.


#2

That is correct. For [1 5 2] you give [ 1 2 1] (1+2+1=4) and for [1 2 5] you give [1 2 3] (1+2+3=6).