#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, k, s, s1, s2, mx, a[N];
int main()
{
	ll i;
	cin >> n >> k;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]), s += max(0LL, a[i]);
	for (i = 0; i < k; i++) s1 += max(0LL, a[i]), s2 += a[i];
	mx = s - s1 + max(0LL, s2);
	for (i = k; i < n; i++) {
		s1 += max(0LL, a[i]) - max(0LL, a[i - k]);
		s2 += a[i] - a[i - k];
		mx = max(mx, s - s1 + max(0LL, s2));
	}
    cout << mx << endl;
    return 0;
}