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 amins = a[0]; let mut dp = vec![0usize; 1<> j) & 1) == 1 { continue; } let idx = i | (1 << j); if dp[idx] % amins < dp[i] % a[j] % amins { dp[idx] = dp[idx].max(dp[i] % a[j]); } } } println!("{}", dp[(1<