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

void main ()
{
	int n, k;
	while (readf (" %s %s", &n, &k) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(long)).array;
		long [] s = [0L];
		foreach (c; a)
		{
			s ~= s.back + c;
		}
		long [] t = [0L];
		foreach (c; a)
		{
			t ~= t.back + max (0L, c);
		}

		debug {writeln (s); writeln (t);}
		long res = long.min / 4;
		long cur = t.back;
		debug {writeln (s); writeln (t); writeln (cur);}
		foreach (i; k..n + 1)
		{
			debug {writeln (i, " ", t[i] - t[i - k], " ",
			    s[i] - s[i - k]);}
			res = max (res, cur - (t[i] - t[i - k]) +
			    max (0L, (s[i] - s[i - k])));
		}

		writeln (res);
	}
}
