Can u help for SUMQ of june17

This is my code : https://www.codechef.com/viewsolution/18896151 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: https://www.codechef.com/viewsolution/18898483

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.