WRONG ANSWER in all the test cases of problem INVERSIONCOUNT

CODE:https://ide.codingblocks.com/s/117408
My code is giving the right output for the given test case and all the possible test cases I could think of. But it is giving wrong answer in the locked test cases. Please tell me which part of my code might be giving the wrong answer.

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

#define ll long long

ll k[100005], n;

ll merge(ll *a, ll si, ll ei)
{
     if (si >= ei)
          return 0;

     ll count = 0;
     ll mi = (si + ei) / 2;

     count = count + merge(a, si, mi) + merge(a, mi + 1, ei);

     ll i = si, j = mi + 1;
     ll d = si;

     while (i <= mi && j <= ei)
     {
          if (a[i] <= a[j])
               k[d++] = a[i++];
          else
          {
               k[d++] = a[j++];
               count = count + (mi - i + 1);
          }
     }

     while (i <= mi)
          k[d++] = a[i++];

     while (j <= ei)
          k[d++] = a[j++];

     for (int i = si; i <= ei; i++)
          a[i] = k[i];

     return count;
}

int main()
{
     int t;
     cin >> t;
     while (t--)
     {
          cin >> n;
          ll a[n];
          for (ll i = 0; i < n; i++)
               cin >> a[i];
          cout << merge(a, 0, n - 1) << "\n";
     }
}

please have a look in this code and try to find where you are going wrong.

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.