#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
void solve(){
int n, k, l;
cin >> n >> k >> l;
queue<int> q;
for(int i = 0; i < n; i++){
int x;
cin >> x;
q.push(x);
}
double t = q.front();
q.pop();
double dist = k;
double prev = 0;
while(dist < l && q.size()){
while(dist < l && q.size() && q.front() - t <= dist){
if(q.front() < dist){
prev = min(dist, q.front() + t);
}else prev = dist;
if(dist - prev < k)dist = prev + k;
q.pop();
}
if(dist - prev >= k){
int need = dist - k - prev;
t += need;
prev += need;
}
if(q.size() && dist < l){
double x = q.front() - t;
double req = (x + dist) / 2 - dist;
t += req;
dist += req;
}
}
if(dist >= l){
cout << floor(2 * t) << "\n";
}else{
double need = max(0.0, l - k - prev);
t += need;
cout << floor(2 * t) << "\n";
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7Cgp2b2lkIHNvbHZlKCl7CglpbnQgbiwgaywgbDsKCWNpbiA+PiBuID4+IGsgPj4gbDsKCQoJcXVldWU8aW50PiBxOwoJCglmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKCQlpbnQgeDsKCQljaW4gPj4geDsKCQlxLnB1c2goeCk7Cgl9CgkKCWRvdWJsZSB0ID0gcS5mcm9udCgpOwoJcS5wb3AoKTsKCWRvdWJsZSBkaXN0ID0gazsKCWRvdWJsZSBwcmV2ID0gMDsKCXdoaWxlKGRpc3QgPCBsICYmIHEuc2l6ZSgpKXsKCQl3aGlsZShkaXN0IDwgbCAmJiBxLnNpemUoKSAmJiBxLmZyb250KCkgLSB0IDw9IGRpc3QpewoJCQlpZihxLmZyb250KCkgPCBkaXN0KXsKCQkJCXByZXY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