#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll a[100010], sum[100010], sum2[100010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum[i + 1] = a[i];
		if (a[i] > 0) sum2[i + 1] = a[i];
	}

	for (int i = 1; i <= N; i++) {
		sum[i] += sum[i - 1];
		sum2[i] += sum2[i - 1];
	}

	ll ans = 0;
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, sum2[N] - sum2[i + K] + sum2[i] + max(sum[i + K] - sum[i], 0LL));
	}
	cout << ans << endl;
	return 0;
}