I am getting wrong answer for the question of MAXDIFF (practice(easy level)) can anyone help me out?

#include <stdio.h>
int main(void) {

int a;
scanf("%d",&a);
while(a!=0)
{
    int b,c;
    scanf("%d",&b);
   
    scanf("%d",&c);
     int d,e,f,g,h,temp;
     long long int ar[b];
   long long int count=0,count1=0;
   long long int result=0;
    for(d=0;d<b;d++)
    {
        scanf("%lld",&ar[d]);
    }
    for(e=0;e<b;e++)
    {
       
        for(f=0;f<b;f++)
        {
            if(ar[f]<ar[f+1])
            {
                temp=ar[f+1];
                
                ar[f+1]=ar[f];
                ar[f]=temp;
            }
        }
        }
        g=b-c;
        for(f=0;f<g;f++)
        {
            
            count=count+ar[f];
            
        }
        for(h=g;h<b;h++)
        {
            count1=count1+ar[h];
            
        }
        
        result=abs(count-count1);
        printf("%lld\n",result);
    a--;
}
return 0;

}