#include<cstdio>
#include<iostream>
#define maxn 100010
using namespace std;
typedef long long LL;
LL z[maxn],sum[maxn],ans;
LL max(LL x,LL y){
	return x>y?x:y;
}
int main(){
#ifdef xunzhen
	freopen("count.in","r",stdin);
	freopen("count.out","w",stdout);
#endif
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		sum[i]=sum[i-1]+t;
		if (t>0) z[i]=z[i-1]+t;
		else z[i]=z[i-1];
	}
	for (int i=0;i<=n-k;i++){
		int j=i+k;
		LL a=max(sum[j]-sum[i],0);
		LL b=z[i]+z[n]-z[j];
		ans=max(ans,a+b);
	}
	cout<<ans<<endl;
	return 0;
}