var
	N,K,i:Longint;
	s,a,b:Array[0..100000]of int64;
	ans,sum:int64;
function my(d:Longint):Longint;
begin
	if d>0 then my:=d else my:=0;
end;
begin
	read(N,K);
	for i:=1 to N do read(s[i]);
	a[1]:=s[1];
	b[1]:=my(s[1]);
	for i:=2 to N do begin
		a[i]:=s[i]+a[i-1];
		b[i]:=my(s[i])+b[i-1];
	end;
	ans:=0;
	for i:=0 to N-K do begin
		sum:=my(a[i+K]-a[i]);
		inc(sum,b[i]-b[0]+b[N]-b[i+K]);
		if ans<sum then ans:=sum;
	end;
	writeln(ans);
end.