#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Mod=998244353;

   ll count(vector<int> a,int x){
    int l=0;
    int r=a.size()-1;
    ll ans = 0;
    while(l<r){
        if(a[r]+a[l]<=x){
            ans+=r-l;
            l++;
        }
        else r--;
    }
    return ans;
   } 

void solve() {

    int n,l,r;
    cin >> n >> l >> r;
    vector<int> a(n);

    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());

    ll ans = count(a,r)-count(a,l-1);
    cout << ans << '\n';
}

int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
    int t;
    cin >> t;
    while (t--) solve();
    

    return 0;
}
