#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 1e9 + 7;

ll a[200005];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        ll n, l, r;
        cin >> n >> l >> r;
        ll ans = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        sort(a + 1, a + 1 + n);
        for (int i = 1; i <= n; i++)
        {
            ll min1 = l - a[i];
            if (min1 < 0)
                min1 = 0;
            ll max1 = r - a[i];
            if (max1 <= 0)
                break;
            ll num = 0;
            ll min2 = lower_bound(a + i + 1, a + 1 + n, min1) - a;
            ll max2 = upper_bound(a + i + 1, a + 1 + n, max1) - a - 1;
            if (min2 <= i || max2 == -1)
                continue;
            ans += max2 - min2 + 1;
        }
        cout << ans << endl;
    }

    return 0;
}