use std::io::stdin;
use std::string::String;
use std::cmp::max;

fn main() {
    let n: usize;
    let k: usize;
    {
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut split = line.split_whitespace();
        n = split.next().unwrap().parse().unwrap();
        k = split.next().unwrap().parse().unwrap();
    }
    let a: Vec<i64>;
    {
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let split = line.split_whitespace();
        a = split.map(|s| s.parse().unwrap()).collect();
    }
    let sum = a.iter().filter(|&&i| i >= 0).sum::<i64>();
    let min: i64 = a.windows(k).map(|s| s.iter().filter(|&&i| i > 0).sum()).min().unwrap();
    println!("{}", max(0, sum - min));
}
