use std::io::*; //use std::num; use std::str::FromStr; //use std::time::Instant; fn main() { //let now = Instant::now(); let n: usize = read(); let m: usize = read(); let mut a = vec![0; n]; let mut ans: u64 = 0; let mut flag_start: usize = 0; let mut flag_end: usize; let mut flag_move: bool = false; for _i in 0..a.len() { a[_i] = read(); } for _i in 0..n { if n == 1 && a[0] % 2 == 1{ println!("{}",a[0]) }else if flag_move == false && a[_i] % 2 == 1{ flag_start = _i; flag_move = true; }else if flag_move == true && a[_i] % 2 == 1{ if _i >= n-1 { for _j in flag_start..n{ ans += a[_j]; } println!("{}",ans); ans = 0; } }else if flag_move == false && a[_i] % 2 == 0{ }else if flag_move == true && a[_i] % 2 == 0 { flag_end = _i; if flag_end - flag_start >= m{ for _j in flag_start..flag_end{ ans += a[_j]; } println!("{}",ans); ans = 0; }else{ } flag_move = false; } } //println!("[DEBUG_PRINT] {} ms", now.elapsed().as_millis()); } pub fn min(x: usize, y: usize) -> usize { let z: usize; if x <= y { z = x; } else { z = y; } return z; } pub fn read() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } pub fn read_array() -> Vec { let array: String = read(); let chars: Vec = array.trim().chars().collect::>(); chars } pub fn get_data() -> Vec { let mut s: String = String::new(); std::io::stdin().read_line(&mut s).ok(); let vec: Vec = s .trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect(); vec } pub fn get_chars() -> Vec { let mut s: String = String::new(); std::io::stdin().read_line(&mut s).ok(); let vec: Vec = s.trim().chars().collect::>(); vec }