#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=200005;
int n,m,ans,a[N],sum1[N],sum2[N];
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)sum1[i]=sum1[i-1]+max(a[i],0LL),sum2[i]=sum2[i-1]+a[i];
	for (int i=0;i<=n-m;i++)
		ans=max(ans,max(0LL,sum2[i+m]-sum2[i])+sum1[n]-(sum1[i+m]-sum1[i]));
	printf("%lld",ans);	
}