Can u help for SUMQ of june17

This is my code : CodeChef: Practical coding for everyone i think my approach is ok. but somehow I can’t realise the cause of WA. please help!!

Thanks btw.

Here is an AC solution: CodeChef: Practical coding for everyone

You had made a silly mistake. Array size was a, so you should have sorted array as sort(arr,arr+a+1) since you considered indexing from 1.