#include<iostream>
#include<cstdio>
using namespace std;
long long sum[101000],sum2[101000],a[101000],ans=0;
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){sum[i]=sum[i-1]+a[i];sum2[i]=sum2[i-1];if(a[i]>0)sum2[i]+=a[i];}
	for(int i=1;i<=n-k+1;i++)
	{
		ans=max(ans,sum2[n]-(sum2[i+k-1]-sum2[i-1])+(sum[i+k-1]-sum[i-1]));
		ans=max(ans,sum2[n]-(sum2[i+k-1]-sum2[i-1]));
	}
	printf("%lld",ans);return 0;
}