#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,k;
ll ans=0,kk;
ll a[100010],sa[100010],sb[100010];
int main(){
	scanf("%d%d",&n,&k);
	int i,j;
	sa[0]=0;sb[0]=0;
	for(i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		if(a[i]>0)  sa[i]=sa[i-1]+a[i];
		else  sa[i]=sa[i-1];
		sb[i]=sb[i-1]+a[i];
	}
	for(i=k;i<=n;++i){
		ll xx=sb[i]-sb[i-k],yy=sa[i-k]+sa[n]-sa[i];
		if(xx>0)  yy+=xx;
		ans=max(ans,yy);
	}
	printf("%lld\n",ans);
	return 0;
}