```
int i=0,j=0,sum=0,q=0,k=0,l=0,z=0;
int size = 2*B;
int arr[size];
//New array from First B elements and Last B elements of array A
for(j=0;j<B;j++)
{
arr[j]=A[j];
i++;
}
for(l=0;l<B;l++)
{
arr[i]=A[n1-l-1];
i++;
}
//for(k=0;k<size;k++)
//{
// printf("%d\n",arr[k]);
//}
int max[B], temp=0, m=0,n=0,p=0;
//Arranging the new array in decreasing order
for(m=0; m< size-1; m++)
{
for(n=m+1;n<size; n++)
{
if(arr[m]<arr[n])
{
temp=arr[m];
arr[m]=arr[n];
arr[n]=temp;
}
}
}
//Taking the sum for first B elements from new array
for(p=0; p<B; p++)
{
sum=sum+arr[p];
}
```

// printf("%d",sum);

return sum;