#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int n, k;
lint a[100005];
lint l[100005], r[100005];

int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		l[i] = max(a[i], 0ll);
		r[i] = max(a[i], 0ll);
	}
	for(int i=1; i<=n; i++){
		a[i] += a[i-1];
		l[i] += l[i-1];
		r[n+1-i] += r[n+2-i];
	}
	lint ret = -1e18;
	for(int i=1; i+k-1<=n; i++){
		ret = max(ret, l[i-1] + r[i+k] + max(0ll, a[i+k-1] - a[i-1]));
	}
	cout << ret;
}

