#include<bits/stdc++.h>
#define stdlen 120050
using namespace std;
long long N,arr[stdlen];
long long K,B[stdlen],b[stdlen],w[stdlen];
int main()
{
	scanf("%lld%lld",&N,&K);
	for(long long i=1;i<=N;++i)
	{
		scanf("%lld",&arr[i]);
		B[i]=B[i-1]+arr[i];
		if(arr[i]<0)
		{
			w[i]=w[i-1]+arr[i];
		}
		else
		{
			w[i]=w[i-1];
		}
		if(arr[i]>0)
		{
			b[i]=b[i-1]+arr[i];
		}
		else
		{
			b[i]=b[i-1];
		}
	}
	long long mx=-2e9;
	long long mn=2e9;
	long long mxl,mxr;
	for(long long i=1;i<=N-K+1;++i)
	{
		if(w[i+K-1]-w[i-1]>mx)
		{
			mxl=i;
			mxr=i+K-1;
			mx=w[i+K-1]-w[i-1];
		}
	}
	long long mnl,mnr;
	for(long long i=1;i<=N-K+1;++i)
	{
		if(b[i+K-1]-b[i-1]<mn)
		{
			mnl=i;
			mnr=i+K-1;
			mn=b[i+K-1]-b[i-1];
		}
	}
	long long mnn,mxx;
	mnn=(b[mnl-1]-b[0])+(b[N]-b[mnr]);
	mxx=(b[mxl-1]-b[0])+(B[mxr]-B[mxl-1])+(b[N]-b[mxr]);
	printf("%lld",max(mnn,mxx));
	return 0;
}