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

const int MAXN = 100005;

long long a[MAXN];
int n, k;
long long pre[MAXN], suf[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]), pre[i] = max(a[i], 0ll), suf[i] = max(a[i], 0ll);
	for (int i = 1; i <= n; i++) a[i] += a[i-1], pre[i] += pre[i-1];
	for (int i = n; i >= 1; i--) suf[i] += suf[i+1];
	long long ans = 0;
	for (int i = 1; i+k-1 <= n; i++)
		ans = max(ans, pre[i-1]+suf[i+k]+max(a[i+k-1]-a[i-1], 0ll));
	cout << ans << endl;
	return 0;
}
