#include <bits/stdc++.h>#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);using namespace std;int main() { fIO int T; cin >> T; for (int test_case = 1; test_case <= T; ++test_case) { int N, L; cin >> N >> L; vector<int> bomb(N); for (int i = 0; i < N; ++i) { cin >> bomb[i]; } sort(bomb.begin(), bomb.end()); int current = 0; long long total = 0; for (int i = 0; i < N; ++i) { int go = abs(current - bomb[i]); //현재위치에서 다음 폭탄까지의 거리 if (bomb[i] <= L - bomb[i]) //0이 가까운지 L이 더 가까운지 판단 { total += go + bomb[i]; //총 이동거리 = 폭탄까지 이동 + 폭탄을 0까지 운반하는 거리 current = 0; } else { total += go + (L - bomb[i]); // 이동 + bomb → L current = L; } } cout << "Case #" << test_case << '\n'; cout << total << '\n'; } return 0;}