use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut s: Vec<i64> = vec![0; n + 1];
    let mut t: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        s[i + 1] = s[i] + a[i];
    }
    for i in 0..n {
        t[i + 1] = t[i] + max(a[i], 0);
    }

    let mut ans = 0;
    for i in 0..=n - k {
        ans = max(ans, t[i] + max(0, s[i + k] - s[i]) + t[n] - t[i + k]);
    }
    println!("{}", ans);
}
