#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[110000],n,K;
long long B[110000],C[110000];
int main(){
	scanf("%d%d",&n,&K);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	for (int i=1;i<=n;i++){
		B[i]=B[i-1]+max(A[i],0);
		C[i]=C[i-1]+A[i];
	}
	long long ans=0;
	for (int i=1;i<=n-K+1;i++){
		int l=i,r=i+K-1;
		long long num=B[l-1]+B[n]-B[r];
		ans=max(ans,num+max(C[r]-C[l-1],0ll));
	}
	cout<<ans<<endl;
}