#include <iostream>
using namespace std;

int main() {
	int N, K;
	long a[100010], sum=0, bl=0, wh=0;
	cin >> N >> K;
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    if(a[i]>0) sum += a[i];
	    if(i<K){
	        if(a[i]<0) bl -= a[i];
	        else wh += a[i];
	    }
	}
	long ans=0;
	a[N]=0;
	for(int i=0; i+K<=N; ++i){
	    ans=max(ans, sum-min(bl, wh));
	    if(a[i]<0) bl += a[i];
	    else wh -= a[i];
	    if(a[i+K]<0) bl -= a[i+K];
	    else wh += a[i+K];
	}
	cout << ans << endl;
	return 0;
}
