#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long binpow(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, n, l, r;
  cin >> t;
  while (t--) {
    cin >> n >> l >> r;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long ans = 0;
    for (int i = 0, p, q; i < n; i++) {
      p = l - a[i];
      q = r - a[i];
      auto low = lower_bound(a.begin(), a.end(), p);
      auto up = lower_bound(a.begin(), a.end(), q);
      if (low == a.end()) continue;
      q = up - a.begin();
      p = low - a.begin();
      if (q == n) q = n - 1;
      while (q + 1 < n && a[q + 1] <= r - a[i]) q++;
      while (p < q && p <= i) p++;
      if (p <= q && p > i && a[i] + a[p] >= l && a[i] + a[q] <= r)
        ans += 1LL * (q - p + 1);
    }
    cout << ans << "\n";
  }
  return 0;
}
