#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    long long t, n, l, r, left, right, m, kq1, kq2, ans, a[200001], b[200001];
    cin >> t;
    while (t--){
        ans = 0;
        cin >> n >> l >> r;
        for (int i = 1; i <= n; i++){
            cin >> a[i];
            b[i] = a[i];
        }
        sort(b+1, b+n+1);
        for (int i = 1; i <= n; i++){
            if (a[i] + b[n] < l || a[i] + b[1] > r) continue;
            kq1 = n; kq2 = 1;
            left = 1; right = n;
            while (left <= right){
                m = (left + right) / 2;
                if (b[m] + a[i] >= l){
                    kq1 = m;
                    right = m-1;
                } else left = m+1;
            }
            left = 1; right = n;
            while (left <= right){
                m = (left + right) / 2;
                if (b[m] + a[i] <= r){
                    kq2 = m;
                    left = m+1;
                } else right = m-1;
            }
            ans += kq2-kq1+1;
            if (a[i]*2 >= l && a[i]*2 <= r) ans--;
        }
        cout << ans/2 << '\n';
    }
}