#include <iostream>
#include <algorithm>
using namespace std;
int N, K, a[100009];
int main() {
	cin >> N >> K;
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += (a[i] > 0 ? a[i] : 0);
	}
	long long cur = 0, cs = 0, ret = 0;
	for (int i = 0; i < N; i++) {
		cur += a[i];
		cs += (a[i] > 0 ? a[i] : 0);
		if (i >= K - 1) {
			ret = max(ret, sum - min(cs - cur, cs));
			cur -= a[i - K + 1];
			cs -= (a[i - K + 1] > 0 ? a[i - K + 1] : 0);
		}
	}
	cout << ret << '\n';
	return 0;
}