#include<cstdio>
#include<algorithm>
using namespace std;
int n,k;
long long qzh1[100005],qzh2[100005],a[100005],cnt,ans=-200000000000000;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {scanf("%lld",&a[i]);qzh1[i]=qzh1[i-1];qzh2[i]=qzh2[i-1];if(a[i]>0) qzh1[i]+=a[i];else qzh2[i]+=a[i];}
	for(int i=k;i<=n;++i) ans=max(ans,max(qzh1[n]-qzh1[i]+qzh1[i-k],qzh1[n]+qzh2[i]-qzh2[i-k]));
	printf("%lld\n",ans);
	return 0;
}