#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,k,a[N];
ll ans,sum,s1[N],s2[N];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s1[i]=s1[i-1]+a[i];
		s2[i]=s2[i-1]+max(a[i],0);
	}
	for (int i=1;i<=n-k+1;i++) ans=max(ans,s2[n]-s2[i+k-1]+s2[i-1]+max(s1[i+k-1]-s1[i-1],0ll));
	printf("%lld\n",ans);
	return 0;
}