#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int N, K;
	cin >> N >> K;
	ll ans = -1e18, a[N+1], sum[N+1], pos_sum[N+1];
	sum[0] = 0, pos_sum[0] = 0;
	for(int i=1; i<=N; i++){
		cin >> a[i];
		sum[i] = sum[i-1] + a[i];
		if(a[i] > 0) pos_sum[i] = pos_sum[i-1] + a[i];
		else pos_sum[i] = pos_sum[i-1];
	}
	for(int i=1; i<=N-K+1; i++){
		ll t = sum[i+K-1] - sum[i-1] + pos_sum[i-1] + pos_sum[N] - pos_sum[i+K-1];
		if(t > ans) ans = t;
		ll s = pos_sum[i-1] + pos_sum[N] - pos_sum[i+K-1];
		if(s > ans) ans = s;
	}
	cout << ans << endl;
	return 0;
}