#include #include #include #include using namespace std; /* const int maxn = int(1e8) + 1000; char str[maxn], A[maxn]; int num[10]; int main(){ int t; int count, k, c; scanf("%d", &t); while (t--){ memset(num, 0, sizeof(num)); count = 0; scanf("%s", str); for (int i = 0; str[i]; i++){ if (str[i] != '0')count++; num[str[i] - '0']++; } if (count < 2) { printf("Uncertain\n"); continue; } for (int i = 1; i < 10; i++) if (num[i] != 0){ c = i; num[i]--; break; } k = 0; for (int i = 0; i < 10; i++) while (num[i]){ A[k++] = '0' + i; num[i]--; } for (int i = 0; i < k; i++){ A[i] += c; c = 0; if (A[i] > '9'){ A[i] -= 10; c = 1; } else break; } if (c)printf("%d", c); for (int i = k - 1; i >= 0; i--)printf("%c", A[i]); printf("\n"); } return 0; } */ const int maxn = int(1e6)*3 + 100; typedef __int64 ll; ll bb[maxn]; pair pp[maxn]; pair tt[maxn]; bool cmp(ll a, ll b){ return a > b; } ll p_max(ll a, ll b){ return a > b ? a : b; } ll p_min(ll a, ll b){ return a < b ? a : b; } int main(){ int t; ll n, l, r, cnt, ans; scanf("%d", &t); while (t--){ scanf("%I64d %I64d %I64d", &n, &l, &r); for (int i = 0; i < n; i++) scanf("%I64d", &bb[i]); sort(bb, bb + n, cmp); for (int i = 0; i < n - 1; i++){ pp[i].first = bb[i] + bb[i + 1]; pp[i].second = bb[i] - bb[i + 1] + 1; } tt[0] = pp[0]; cnt = 0; for (int i = 1; i < n-1; i++){ if (pp[i] == pp[i - 1]) continue; if (pp[i].first >= tt[cnt].second){ if (pp[i].second < tt[cnt].second) tt[cnt].second = pp[i].second; } else if( pp[i].first < tt[cnt].second) tt[++cnt] = pp[i]; } ans = 0; for (int i = 0; i <= cnt; i++){ if (tt[i].first <= l || tt[i].second > r) continue; else ans = ans + (p_min(r, tt[i].first - 1) - p_max(l, tt[i].second)) + 1; } printf("%I64d\n",r-l+1-ans); } return 0; }