/* In the name of *Allah* *
 *   Thank You *Parsa*    */
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<ios>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<numeric>
using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;

const int inf_int = 1 << 30;
const ll inf_longlong = 1LL << 62;
const int MOD = 1e9 + 7;

const int N = 2e5 + 5;
int n, a[N], l, r;

void read_input() {
	cin >> n >> l >> r;
	for (int i = 0; i < n; i++) cin >> a[i];
}

void solve() {
	sort(a, a + n);
	ll ans = 0;

	for (int i = 0; i < n; i++) {
		int L = -1, R = i;
		while (R - L > 1) {
			int mid = (L + R) / 2;
			if (l - a[i] <= a[mid]) R = mid;
			else L = mid;
		}
		int rr = R;
		L = -1, R = i;
		while (R - L > 1) {
			int mid = (L + R) / 2;
			if (r - a[i] >= a[mid]) L = mid;
			else R = mid;
		}

		//cout << a[i] << ' ' << rr << ' ' << L << '\n';

		

		ans += max(0, L - rr + 1);
	}
	cout << ans << '\n';
}

void write_output() {
}

int main() {
	ios:: sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

	int test_cases = 1; cin >> test_cases;
	while (test_cases--) {
		read_input(), solve(), write_output();
	}
	return 0;
}
// Thanks *Allah*