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

// count number of pairs (i<j) in sorted array A whose sum ≤ X
ll count_le(const vector<ll>& A, ll X) {
    int n = A.size();
    ll cnt = 0;
    int i = 0, j = n - 1;
    while (i < j) {
        if (A[i] + A[j] <= X) {
            // for this i, all indices from i+1..j paired with i are ≤ X
            cnt += (j - i);
            ++i;
        } else {
            // sum too large, decrease j
            --j;
        }
    }
    return cnt;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        int n;
        ll l, r;
        cin >> n >> l >> r;
        vector<ll> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        sort(a.begin(), a.end());
        // #pairs with sum ≤ r minus #pairs with sum ≤ l-1
        ll ans = count_le(a, r) - count_le(a, l - 1);
        cout << ans << "\n";
    }
    return 0;
}
