fn main() { let mut nk = String::new(); std::io::stdin().read_line(&mut nk).ok(); let nk: Vec = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nk[0]; let k = nk[1]; let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let mut a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); a.sort(); let amin = a[0]; a.reverse(); a.pop(); let mut result = 0usize; let n = a.len(); for i in 0..1<> j) & 1) == 1).map(|j| a[j]).fold(k, |base, modval| base % modval); result = result.max(temp % amin); } println!("{}", result); }