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

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	vector<ll> d(N + 1, 0);
	vector<ll> wl(N + 1, 0);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		d[i + 1] = d[i] + a[i];
		if (a[i] > 0) { wl[i + 1] += a[i]; }
		wl[i + 1] += wl[i];
	}

	ll res = 0;
	for (int i = 0; i <= N - K; ++i) {
		ll tmp = max(0LL, d[i + K] - d[i]);
		tmp += (wl[i] + (wl[N] - wl[i + K]));
		res = max(res, tmp);
	}

	cout << res << endl;

	return 0;
}
