#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, k;
int a[100000];

int ra[100001];
int rs[100001];

signed main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) cin >> a[i];
	
	for (i = 0; i < n; i++) ra[i + 1] = ra[i] + a[i];
	for (i = 0; i < n; i++) rs[i + 1] = rs[i] + a[i] * (a[i] > 0);
	
	int ans = 0;
	for (i = 0; i <= n - k; i++) {
		//最後、[i, i + k)を塗る
		int score = rs[i] + max(0LL, ra[i + k] - ra[i]) + rs[n] - rs[i + k];
		ans = max(ans, score);
	}
	cout << ans << endl;
	return 0;
}