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

#define int64_t long long

int main() {
	int n, K;
	cin >> n >> K;
	vector<int64_t> a(n);
	vector<int64_t> sum(n + 1);
	vector<int64_t> sumP(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
		sumP[i + 1] = sumP[i];
		if (a[i] > 0) {
			sumP[i + 1] += a[i];
		}
	}

	int64_t ans = INT64_MIN;
	for (int i = 0; i + K <= n; i++) {
		ans = max(ans, max(0LL, sum[i + K] - sum[i]) + sumP[i] + sumP[n] - sumP[i + K]);
	}
	cout << ans << endl;
}