#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
long long s[N], p[N];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &a[i]);
		s[i] = s[i - 1] + a[i];
		p[i] = p[i - 1] + (a[i] > 0 ? a[i] : 0);
	}
	long long ans = 0;
	for (int i = 1; i + k - 1 <= n; ++ i) {
		ans = max(ans, p[i - 1] + p[n] - p[i + k - 1] + max(0LL, s[i + k - 1] - s[i - 1]));
	}
	cout << ans << endl;
}

