question link : https://www.codechef.com/ZCOPRAC/problems/ZCO12004

solution link : https://www.codechef.com/viewsolution/36168131

For

4

1 2 4 3

it gives o/p 4. This is not correct answer. You are only checking for pairs (1,2) , (3,4). But you should also check for (2,3)

But the question says to check for every pair of adjacent Knights.

therefore if i give the input:

4

1 2 4 3

then at least two Knights should get their dessert, so chef will select the dessert of price 1 and 3. So the final price should be 4.

Here pairs are (1,2) (2,3) (3,4) (4,1). In all the 4 pairs condition should be satisfied