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

typedef long long ll;
const int maxn=1e5+10;
int n,k,a[maxn];
ll sum[maxn],b[maxn],c[maxn],ans;

inline void chkmax(ll&a,ll b){if(a<b)a=b;}

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+a[i],b[i]=a[i]>0?b[i-1]+a[i]:b[i-1];
	for(int i=n;i;--i)
		c[i]=a[i]>0?c[i+1]+a[i]:c[i+1];
	for(int i=0;i+k<=n;++i){
		chkmax(ans,b[i]+c[i+k+1]);
		chkmax(ans,b[i]+c[i+k+1]+sum[i+k]-sum[i]);
	}
	cout<<ans<<endl;
	return 0;
}