#include <bits/stdc++.h>
#define LLONGMAX 9223372036854775807
#define INTMAX 2147483647
#define LLONGMIN -9223372036854775806
#define INTMIN -2147483646
using namespace std;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr); cout.tie(nullptr);
   int T; cin>>T;
   while(T--)
   {
      long long n, l, r; cin>>n>>l>>r;
      vector<int> arr(n);   
      for(int i = 0; i < n; i++)
         cin>>arr[i];
      sort(arr.begin(), arr.end());
      long long ans = 0;
      for(int i = 0; i < n; i++)
      {
         auto p = lower_bound(arr.begin(), arr.end(), l - arr[i]);
         auto e = upper_bound(arr.begin(), arr.end(), r - arr[i]);
         if(e == arr.begin())
            continue;
         e--;
         if(e == arr.begin() && arr[0] > r - arr[i])
            continue;
         if(p == arr.end())
            continue;
         if((long long)(p - arr.begin()) <= i && i <= (long long)(e - arr.begin()))
            ans--;
         ans += ((long long)(e - p) + 1); 
      }
      cout<<ans / 2<<endl;
   }
}
