#![allow(non_snake_case, unused_imports)] use proconio::{input, marker::Usize1, marker::Chars}; use itertools::Itertools; #[allow(unused_macros)] macro_rules! d { ( $( $x:expr ),* $(,)? ) => { eprintln!( concat!( $( stringify!($x), "={:?} " ),* ), $( $x ),* ); }; } #[allow(dead_code)] fn yn(b: bool) -> &'static str { if b { "Yes" } else { "No" } } fn main() { input! { T: usize, } for _ in 0..T { input! { N: usize, K: i64, A: [i64; N], } let slis = A.into_iter().sorted().collect_vec(); let ans = match slis.as_slice() { [head, rest@..] => { rest.iter() .copied() .chain(std::iter::once(head - K)) .reduce(|a, b| a * b).unwrap() }, &[] => unreachable!() }; println!("{}", ans); } }