#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int a[N];
s64 s[N],s1[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n,k;
	cin>>n>>k;
	rep(i,1,n)
	{
		scanf("%d",a+i);
		s[i]=s[i-1]+a[i];
		s1[i]=s1[i-1]+(a[i]>0?a[i]:0);
	}
	s64 ans=0;
	rep(i,1,n-k+1)chmax(ans,s1[i-1]+s1[n]-s1[i+k-1]+max((s64)0,s[i+k-1]-s[i-1]));
	cout<<ans;
}