import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int n, k;
    scan(n, k);
    auto a = readln.split.to!(int[]);

    auto presum = new long[](n + 1);
    auto possum = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        presum[i] = a[i-1] + presum[i-1];
        possum[i] = max(a[i-1], 0) + possum[i-1];
    }

    long ans;
    foreach (i ; 0 .. n - k + 1) {
        long t = possum[n] - (possum[i + k] - possum[i]) + max(0, presum[i + k] - presum[i]);
        ans = max(ans, t);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
