#include <stdio.h>
#include <string.h>
#define MN 100005
long long n,k,a[MN],cnt[MN],K,ans=0;
long long mmin=0x7fffffffffffffff,il,ir;
long long mmax=-0x7fffffffffffffff,al,ar;
inline long long min(long long a,long long b){return a<b?a:b;}
inline long long max(long long a,long long b){return a>b?a:b;}
int main(){
//	freopen("b.in","r",stdin);
	memset(cnt,0,sizeof(cnt));
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		cnt[i]=cnt[i-1]+a[i];
		if(i>=k){
			if(cnt[i]-cnt[i-k]<mmin){
				mmin=cnt[i]-cnt[i-k];
				ir=i,il=i-k+1;
			}
			if(cnt[i]-cnt[i-k]>mmax){
				mmax=cnt[i]-cnt[i-k];
				ar=i,al=i-k+1;
//				printf("%lld %lld %lld\n",al,ar,mmax);
			}
		}
		if(a[i]>0)ans+=a[i];
	}
	int l,r,flg;
	K=max(max(mmin,0),mmax);
	if(max(mmin,0)<mmax){
		l=al,r=ar; flg=1;
	}else{
		l=il,r=ir; flg=0;
	}
//	printf("%d %d\n",l,r);
	for(int i=l;i<=r;i++){
		if(a[i]>0)ans-=a[i];
	}
//	printf("%d\n",ans);
	printf("%lld",ans+K);
}