#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define rep(i, n) for (int i = 0; i < n; i++)

void solve()
{
    ll n, l, r;
    cin >> n >> l >> r;
    vector<ll> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll count = 0;
    rep(i, n)
    {
        int left = i + 1;
        int right = n - 1;
        int leftres = -1;
        while (left <= right)
        {
            int mid = (left + right) / 2;
            if (v[i] + v[mid] >= l && v[i] + v[mid] <= r)
            {
                leftres = mid;
                right = mid - 1;
            }
            else if (v[i] + v[mid] > r)
            {
                right = mid - 1;
            }
            else if (v[i] + v[mid] < l)
            {
                left = mid + 1;
            }
        }
        if (leftres >= 0)
        {
            left = i + 1;
            right = n - 1;
            int rightres = -1;
            while (left <= right)
            {
                int mid = (left + right) / 2;
                if (v[i] + v[mid] >= l && v[i] + v[mid] <= r)
                {
                    rightres = mid;
                    left = mid + 1;
                }
                else if (v[i] + v[mid] > r)
                {
                    right = mid - 1;
                }
                else if (v[i] + v[mid] < l)
                {
                    left = mid + 1;
                }
            }
            count += rightres - leftres + 1;
        }
    }
    cout << count << endl;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
#endif
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}