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

long long cum[100010],cum_p[100010];
int main(void){
	int n,k; scanf("%d%d",&n,&k);
	vector<long long> a(n);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	for(int i=0;i<n;i++){
		cum[i+1] = cum[i]+a[i];
		cum_p[i+1] = cum_p[i] + max(0LL,a[i]);
	}
	long long ans = -(long long)1e15;
	for(int i=0;i<=n-k;i++){
		long long res = (cum_p[i]-cum_p[0])+max(0LL,cum[i+k]-cum[i])+(cum_p[n]-cum_p[i+k]);
	 	ans = max(ans,res);
	}
	cout << ans << endl;
	return 0;
}