#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

ll f(ll a,ll b){return (a<b)?b:a;}

int main(){
	ll n,k,ans=0;
	cin>>n>>k;
	ll a[n],s[n+1],t[n+1];
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(i==0){
			s[i]=a[i];
			t[i]=f(a[i],0);
		}else{
			s[i]=s[i-1]+a[i];
			t[i]=t[i-1]+f(a[i],0);
		}
	}
	rep(i,n-k+1){
		if(i==0)ans=f(ans,s[i+k-1]+t[n-1]-t[i+k-1]);
		else ans=f(ans,f(0,s[i+k-1]-s[i-1])+t[i-1]+f(t[n-1]-t[i+k-1],0));
	}
	cout<<ans<<endl;
	return 0;
}