#include using namespace std; #define Loop(x,l,r) for (ll x = ll(l); x < ll(r); ++x) #define LoopR(x,l,r) for (ll x = ll(r)-1; x >= ll(l); --x) #define Looc(x,l,r) for (ll x = ll(l); x <= ll(r); ++x) #define LoocR(x,l,r) for (ll x = ll(r); x >= ll(l); --x) #define int ll typedef long long ll; typedef pair pii; typedef pair pll; #ifndef DB #define DB 0 #define endl '\n' #endif #define debugl(l) if constexpr ((l) < DB) #define debug debugl(0) void solve() { int n, k; ll len; cin >> n >> len >> k; vector pos(n); for (auto &x : pos) cin >> x; auto can = [&](ll go) { if (go >= 2*len) return true; map ps; for (auto p : pos) { auto lf = p - go; auto ri = p + go; if (lf < 0) { ps[lf + len] += 1; //ps[len] -= 1; ps[0] += 1; ps[ri] -= 1; } else if (ri >= len) { ps[lf] += 1; //ps[len] -= 1; ps[0] += 1; ps[ri - len] -= 1; } else { ps[lf] += 1; ps[ri] -= 1; } } ll sum = 0; for (auto [x, y] : ps) { sum += y; if (sum < k) return false; } return true; }; ll l = 0, r = len; while (l < r) { ll mid = (l+r)/2; if (can(mid)) r = mid; else l = mid+1; } cout << l << '\n'; } signed main() { cin.tie(0) -> sync_with_stdio(false); int t = 1; cin >> t; while (t--) solve(); }