#include <iostream>
#include <algorithm>

using namespace std;

long long a[100010],sum[100010],mx[100010],ans=0;

int main(){
	int i,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	
	sum[0] = 0; mx[0] = 0;
	
	for(i=1;i<=n;i++){
		sum[i] = sum[i-1] + a[i-1];
		mx[i] = mx[i-1] + max(a[i-1],(long long)0);
	}
	
	for(i=0;i<=n-k;i++){
		ans = max(ans,sum[k+i]-sum[i]+mx[i]+mx[n]-mx[k+i]);
		ans = max(ans,mx[i]+mx[n]-mx[k+i]);
	}
	cout << ans << endl;
}
	
	