Can u help for SUMQ of june17

This is my code : 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:

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.