#include <bits/stdc++.h>

using namespace std;

const long long INF = 1e18;

int n,k,i,j,a[100005];
long long l[100005],r[100005],sum[100005];

int main(){
	scanf("%d%d", &n, &k);
	for(i = 1; i <= n; i++)
	scanf("%d", &a[i]);
	
	for(i = 1; i <= n; i++)
	l[i] = l[i - 1] + max(0, a[i]);
	for(i = n; i >= 1; i--)
	r[i] = r[i + 1] + max(0, a[i]);
	for(i = 1; i <= n; i++)
	sum[i] = sum[i - 1] + a[i];
	
	long long res = - INF;
	
	for(i = 1; i <= n - k + 1; i++)
	res = max(res, max(0LL, sum[i + k - 1] - sum[i - 1]) + l[i - 1] + r[i + k]);
	
	printf("%lld\n", res);
}
