Help me in solving MAJIK problem

My issue

We are taking elements P+Q times then we are adding it to the maximum but doing this increases the operations from P+Q to P+Q+1 right ?

My code

# cook your dish here

Problem Link: MAJIK Problem - CodeChef

No, first you perform p+q operations and find the maximum distance between min and max element

then we return the result as (max-min) + maximum_distance

(max-min) + maximum_distance → this is return statement not comes in operations