#include <iostream>
using namespace std;

int main() {
int n,k,a[100000];
long long s=0,p=0,m=0,l;
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>0)s+=a[i];
}
l=s;
for(int i=0;i<n;i++){
    if(a[i]>=0){
        p+=a[i];
    }else{
        m-=a[i];
    }
    if(i>=k-1){
        l=min(l,min(p,m));
        if(a[i-k+1]>=0){
            p-=a[i-k+1];
        }else{
            m+=a[i-k+1];
        }
    }
}
//cout<<s<<","<<l<<endl;
cout<<s-l<<endl;
	return 0;
}