Code is not being accepted

Could you please check why the code is not working. Code: https://onlinegdb.com/aYDOdkx9c

We can use greedy approach for this question. First we will sort the given array. Then the minimum and maximum sum expressions will be:

Time Complexity : O(NlogN)

Code–>

#include <bits/stdc++.h>
#define nn 100100
#define ll long long int
 
using namespace std;
 
ll a[nn];
 
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
            cin>>a[i];
        ll mx=0,mn=0;
        sort(a,a+n);
        for(int i=0;i<n/2;i++)
        {
            mx+=(a[i+n/2]-a[i]);
            mn+=(a[2*i+1]-a[2*i]);
        }
        cout<<mn<<" "<<mx<<endl;
    }
    return 0;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.