Can Anyone Help me to figure out what's wrong with 1st testcase. I am getting WA on it

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

You are assuming that the largest element is involved in the solution but that is not necessary true. Consider for example this case:
n=3
A={3,8,9}