2 Test Cases Are Failing

Could You Please Check My Recursive Equation For The Following Problem My 2 test cases are failing don’t know why

@vikram.keswani108
You have not considered the fact that An and A1 are also adjacent (It’s a circular list). Consider this testcase
3
10 20 1
Output should be 42 { 10+1 = 11 => (11,20), 11+20 =31 so total penalty=11+31 =42 } but your code is giving 52.