#include<bits/stdc++.h>
using namespace std;

long long a[100005],sum1[100005],sum2[100005],ans;
int n,k;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		sum1[i]=sum1[i-1],sum2[i]=sum2[i-1];
		if(a[i]>=0)
		sum1[i]=sum1[i-1]+a[i];
		else sum2[i]=sum2[i-1]+a[i];
	}
	ans=sum1[n];
	long long ma=(1e15);
	for(int i=1;i<=n-k+1;++i)
	{
		ma=min(sum1[i+k-1]-sum1[i-1],ma);
		ma=min(sum2[i-1]-sum2[i+k-1],ma);
	}
	printf("%lld",ans-ma);
}