fn read() -> (usize, Vec) { use std::io::*; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let mut next = || it.next().unwrap(); let n: usize = next().parse().unwrap(); let m: usize = next().parse().unwrap(); (m, (0..n).flat_map(|_| next().parse()).collect()) } fn main() { let (mut m, a) = read(); const MOD: u32 = 1_234_567_891; let mut dp = vec![1]; while m > 0 { for &a in a.iter() { let mut next = vec![0u32; dp.len() + a]; next[..dp.len()].clone_from_slice(&dp); for (next, dp) in next[a..].iter_mut().zip(dp.iter()) { *next += *dp; } dp = next; for dp in dp.iter_mut() { *dp %= MOD; } } let mut next = vec![]; for (i, dp) in dp.iter().enumerate() { if i & 1 == m & 1 { next.push(*dp); } } dp = next; m >>= 1; } println!("{}", dp[0]); }