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