macro_rules! read_line_to_tuple { ( $( $t:ty ),* ) => {{ let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let mut iter = input.split_whitespace(); ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* ) }}; } macro_rules! read_line_to_collection { ( $t:ty ) => {{ let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let iter = input.split_whitespace(); iter.map(|x| x.parse().unwrap()).collect::<$t>() }}; } const MAX: usize = 20_000; const MOD: i32 = 1_000_000_007; fn main() { let (n, k) = read_line_to_tuple!(usize, usize); let a = read_line_to_collection!(Vec); let mut dp = vec![0; MAX as usize + 1]; dp[MAX / 2] = 1; for i in 0..n { let x = a[i] - k as i32; if x < 0 { for j in (-x)..=(MAX as i32) { dp[(j + x) as usize] += dp[j as usize]; dp[(j + x) as usize] %= MOD; } } else { for j in (0..=(MAX as i32 - x)).rev() { dp[(j + x) as usize] += dp[j as usize]; dp[(j + x) as usize] %= MOD; } } } let mut ans = 0; for i in (MAX / 2)..=MAX { ans = (ans + dp[i]) % MOD; } println!("{}", ans - 1); }