#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100005
#define LL long long
int n,k;
LL s[MAXN],sum[MAXN];
#define INF 0x7fffffffffffffff
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		s[i]=s[i-1]+x;
		if(x>0) sum[i]=sum[i-1]+x;
			else sum[i]=sum[i-1];
	}
	LL ans=-INF;
	for(int i=1;i<=(n-k+1);i++)
	{
		LL res=0;
		int j=i+k-1;
		if(s[j]-s[i-1]>0/*注意有值和大于0是有区别的*/) res+=s[j]-s[i-1];
		res+=sum[i-1]-s[0];
		res+=sum[n]-sum[j];
		ans=max(ans,res);
	}
	printf("%lld\n",ans);
	return 0;
}
