#include<iostream>
#include<algorithm>

using namespace std;

int const N = 1e5 + 41;
int a[N], n, k;
long long pref[N], prefP[N], ans;

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		pref[i] = pref[i-1] + a[i];
		prefP[i] = prefP[i-1] + max(0, a[i]);
	}

	for(int i=1;i<=n-k+1;++i){
		long long pans = prefP[i-1] + prefP[n] - prefP[i+k-1];
		pans += max(0LL, pref[i+k-1] - pref[i-1]);
		ans = max(ans, pans);
	}
	printf("%lld\n",ans);




	return 0;
}