#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 100005
using namespace std;
int n,k,a[MN];
long long ans,s[MN],ss[MN];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),s[i]=s[i-1]+a[i],ss[i]=ss[i-1]+max(a[i],0);
	for(int i=0;i<=n-k;i++)ans=max(ans,ss[n]-ss[i+k]+ss[i]+max(0LL,s[i+k]-s[i]));
	printf("%lld\n",ans);
}

