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

void main(){
	int n, k;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		n = tmp[0], k = tmp[1];
		}
	long[] as = readln.chomp.split.map!(to!long).array;
	
	long[] bs = as.map!(x => (x > 0)? 0: x).array;
	long[] cs = as.map!(x => (x > 0)? x: 0).array;
	
	BigInt x = bs[0 .. k].reduce!("a + b");
	BigInt y = cs[0 .. k].reduce!("a + b");
	BigInt xmax = x;
	BigInt ymin = y;
	int ixmax = 0;
	int iymin = 0;
	for(int i = 1; i + k <= n; i ++){
		x -= bs[i - 1];
		x += bs[i + k - 1];
		y -= cs[i - 1];
		y += cs[i + k - 1];
		if(x > xmax){
			xmax = x;
			ixmax = i;
			}
		if(y < ymin){
			ymin = y;
			iymin = i;
			}
		debug writeln(x, " ", xmax, "; ", y, " ", ymin);
		}
	
	BigInt ans1;
	for(int i = 0; i < n; i ++){
		if(i < ixmax || ixmax + k <= i){
			if(as[i] > 0) ans1 += as[i];
			debug writeln(as[i], as[i] > 0);
			}
		else{
			ans1 += as[i];
			debug writeln(as[i], " *");
			}
		}
	debug writeln(ans1);
	
	BigInt ans2;
	for(int i = 0; i < n; i ++){
		if(i < iymin || iymin + k <= i){
			if(as[i] > 0) ans2 += as[i];
			debug writeln(as[i], as[i] > 0);
			}
		else{
			ans2 += 0;
			debug writeln(as[i], " -");
			}
		}
	debug writeln(ans2);
	
	BigInt ans = max(ans1, ans2);
	ans.writeln;
	}