#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e5+5;
int n,k,a[N];
LL sum,ans,s[N];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		if(a[i]>0)
			s[i]=s[i-1]+a[i];
		else s[i]=s[i-1];
	} 
	for(int i=1;i<=k;++i) sum+=a[i];
	ans=max(sum+s[n]-s[k],s[n]-s[k]);
	for(int i=k+1;i<=n;++i){
		sum+=a[i]-a[i-k];
		ans=max(ans,max(sum+s[i-k]+s[n]-s[i],s[i-k]+s[n]-s[i]));
	}
	cout<<ans<<endl;
	return 0;
}