#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; const int maxn = 100005; LL a[maxn]; void work() { int n; LL L, R; scanf("%d%lld%lld", &n, &L, &R); for(int i = 1; i <= n; i++) scanf("%lld", &a[i]); sort(a+1, a+n+1); LL ans = 0; for(int i = n; i >= 2; i--) { if(R < L) break; LL mx = a[i] + a[i-1] - 1; LL mi = a[i] - a[i-1] + 1; if(R > mx) ans += R - max(mx, L-1); R = min(R, mi-1); } if(R > L) ans += R - L + 1; printf("%lld\n", ans); } int main() { int _; scanf("%d", &_); while(_--) { work(); } return 0; }