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

int N,K;
ll acc [100001];

int main()
{
	scanf("%d%d",&N,&K);
	vector<ll> A(N);
	for(int i = 0;i < N;i++){
		scanf("%lld",&A [i]);
		acc [i + 1] = acc [i] + (A [i] >= 0 ? A [i] : 0);
	}

	int l = 0,r = 0;
	ll sum = 0;
	while(r - l < K){
		sum += A [r];
		r++;
	}

	ll ans = 0;
	for(;l <= N - K;l++){
		while(r - l < K){
			sum += A [r];
			r++;
		}
		ans = max(ans,(sum >= 0 ? sum : 0) + acc [N] - acc [r] + acc [l]);
		sum -= A [l];
	}

	printf("%lld\n",ans);

	return 0;
}
