WA in CHCBOX

https://www.codechef.com/viewsolution/30686577

i am first calculating first and last occurence of max element and then checking for condition that max element must be from index n/2 to n and if not then performing shifts to satisfy the above condition

Can anyone check my i am not able to understand the mistake