#include #include using namespace std; typedef long long ll; int T,n; ll L,R,a[100010],b[100010],ans; ll calc(ll x,ll y) { //printf("%lld %lld\n",x,y); x=max(x,L);y=min(y,R); if (x>y) return 0; return y-x+1; } ll Calc(int i) { //printf("%d\n",i); if (i==1) return calc(L,min(b[1],a[1])); if (i==2) return calc(a[1]+1,min(min(a[2]-a[1],b[2]),a[2])); if (i==n) return calc(max(a[n-1]+a[n-2],a[n-1]+1),min(a[n]-a[n-1],a[n])); if (i==n+1) return calc(max(a[n-1]+a[n],a[n]+1),R); return calc(max(a[i-2]+a[i-1],a[i-1]+1),min(min(b[i],a[i]-a[i-1]),a[i])); } int main() { scanf("%d",&T); while (T--) { scanf("%d%I64d%I64d",&n,&L,&R); for (int i=1;i<=n;i++) scanf("%I64d",&a[i]); sort(a+1,a+n+1); b[n-1]=a[n]-a[n-1]; for (int i=n-2;i>=1;i--) b[i]=min(b[i+1],a[i+1]-a[i]); ans=0; if (n==2) { ans+=Calc(1)+Calc(3); ans+=calc(a[1]+1,min(a[2]-a[1],a[2])); printf("%I64d\n",ans); continue; } for (int i=1;i<=n+1;i++) ans+=Calc(i); printf("%I64d\n",ans); } }