#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n, k;
long long qian[N], quj[N], sum[N], ans;
int main() {
    scanf ("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
    	scanf("%d",&a[i]);
		sum[i] = sum[i - 1] + a[i];
		qian[i] = qian[i - 1] + max(a[i], 0);
	}
    quj[n + 1] = 0;
    for (int i = n; i >= 1; i--)
		quj[i] = quj[i + 1] + max(a[i], 0);
    ans = 0;
    for (int i = 0; i <= n - k; i++)
        ans = max(ans, qian[i] + quj[i + k + 1] + max(sum[i + k] - sum[i], 0ll));
    printf ("%lld\n", ans);
    return 0;
}