#include<iostream>
#include<cstdio>
#include<cstring>
template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
typedef long long ll;
const int N=101000;
ll s[N],t[N];
ll ans;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&s[i]);
		t[i]=t[i-1];
		if(s[i]>0)t[i]+=s[i];
		s[i]+=s[i-1];
	}
	ans=0;
	for(int i=k;i<=n;i++)
		check_max(std::max(s[i]-s[i-k],0ll)+t[i-k]+t[n]-t[i],ans);
	printf("%lld\n",ans);
	return 0;
}
