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(); a.reverse(); let amins = a.pop().unwrap(); let n = n-1; let mut result = k % amins; for i in 0..1<> j) & 1) == 1 { val %= a[j]; } } result = result.max(val % amins); } println!("{}", result); }