#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll a[100000], sum[100001], m[100000];
int main() {
	int n, k; scanf("%d%d", &n, &k);
	rep(i, n)scanf("%lld", &a[i]);
	for (int i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + a[i - 1];
		m[i] = max(m[i - 1], m[i - 1] + a[i - 1]);
	}
	ll Max = 0;
	rep(i, n - k + 1) {
		ll p = sum[i + k] - sum[i];
		ll l = m[i], r = m[n] - m[i + k];
		Max = max(Max, (p < 0 ? 0 : p) + l + r);
	}
	printf("%lld\n", Max);
}