It is mentioned in the question that n is always even but there are test cases with odd no of elements.
Optimal Strategy for a Game
@Cheshtha
Yeah u r right i have checked and found some testcases are having odd no of elements .i will inform this to the team.
btw we can frame a logic that work for even as well as odd.
Yeah ,I have solved the problem now. I was just informing about the issue.