#include<cstdio>
using namespace std;
long long Max(long long a,long long b){return a>b?a:b;}
int n,k;
long long a[100005],sum[200005],ans,ksum[200005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){scanf("%lld",&a[i]);if(a[i]>0) sum[i]+=a[i];sum[i]+=sum[i-1];ksum[i]=ksum[i-1]+a[i];}
	for(int i=0;i<=n;i++)
	{
		if(i+k>n) break;
		else ans=Max(ans,sum[i]+sum[n]-sum[i+k]+Max(0,1ll*ksum[i+k]-ksum[i]));
	}
	printf("%lld",ans);
	return 0;
}