Dividing Array Problem

Prob: https://hack.codingblocks.com/practice/p/368/600

sol:
#include<bits/stdc++.h>
using namespace std;

int main(){

int t;
cin>>t;

for(int i=0;i<t;i++){
    
    int n;
    cin>>n;
    
    int arr[n];
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    sort(arr,arr+n);
    
    int arr1[n/2];
    int arr2[n/2];
    
    for(int i=0;i<n/2;i++){
        arr1[i] = arr[i];
    }
    
    for(int i=0;i<n/2;i++){
        arr2[i] = arr[n-1-i];
    }
    
    int maxSum = 0;
    
    for(int i=0;i<n/2;i++){
        maxSum+=((arr2[i]-arr1[i])*(n/4));
    }
    
    int c=0;
    int k=0;
    
    for(int i=0;i<n;i++){
        if(i%2==0){
            arr1[c++] = arr[i];
        }
        else{
            arr2[k++] = arr[i];
        }
    }
    
    int minSum=0;
    
    for(int i=0;i<c;i++){
        minSum+=((arr2[i]-arr1[i])*(n/4));
    }
    
    cout<<minSum<<" "<<maxSum<<endl;
}

return 0;

}

Cant understand whats wrong with the code?
I guess the definition of difference is not clearly given

abhinav check this
https://ide.codingblocks.com/#/s/16632
and also save ur code at online IDE of coding block and post the link here i will mark ur mistake
:slightly_smiling_face:

Thanks man!
s
my sol link: https://ide.codingblocks.com/#/s/16922